Automatically powers off the machine when it has been idle long enough, there are no active SSH sessions, and the battery is not charging.
The idle threshold depends on lid state:
- About 30 minutes when the lid is open
- About 5 minutes when the lid is closed
This is intended for the Argon ONE UP CM5 laptop, to help save battery power: the device does not currently support sleep, so it remains continuously on by default.
This project installs:
- A script at
~/.local/bin/argononeup-automatic-shutdown - A user systemd service at
~/.config/systemd/user/argononeup-automatic-shutdown.service
The service is enabled and started immediately on install, and will automatically restart if it exits unexpectedly.
The script runs in a loop and:
- Queries GNOME's idle monitor over D-Bus (
org.gnome.Mutter.IdleMonitor) to get idle time. - Checks lid state using
gpioget --chip gpiochip0 GPIO27. - Selects the idle threshold based on lid state: 30 minutes if open, 5 minutes if closed.
- Checks for active SSH sessions (
who). - Checks battery charging state from
/sys/class/power_supply/BAT0/status. - If battery status is
Charging, shutdown is skipped. - If charging has just stopped, shutdown is still skipped for up to 5 minutes after the last
Chargingstate. - If idle time is over the current threshold, no SSH sessions are active, and charging/grace conditions are not active, it powers off the machine.
- Linux with
systemd(user-level systemd service support) - GNOME session (uses Mutter idle monitor over D-Bus)
bash,gdbus,sed,grep,who,gpioget- Standard Unix utilities (
install,mkdir)
From the repository directory:
chmod +x install uninstall argononeup-automatic-shutdown.sh
./installWhat install does:
- Copies
argononeup-automatic-shutdown.shto~/.local/bin/argononeup-automatic-shutdown(user-local) - Copies
argononeup-automatic-shutdown.serviceto~/.config/systemd/user/(user-level systemd) - Runs
systemctl --user daemon-reload - Enables and starts the service with
systemctl --user enable --now - No
sudorequired
From the repository directory:
./uninstallWhat uninstall does:
- Disables and stops the service (if running)
- Removes
~/.config/systemd/user/argononeup-automatic-shutdown.service - Removes
~/.local/bin/argononeup-automatic-shutdown - Runs
systemctl --user daemon-reload - No
sudorequired
systemctl --user status argononeup-automatic-shutdown.servicejournalctl --user -u argononeup-automatic-shutdown.service -fOr view recent logs:
journalctl --user -u argononeup-automatic-shutdown.service -n 50- The service is a user-level service and is tied to the graphical session. It starts when you log in and stops when you log out.
- SSH session detection is based on
whooutput. - Lid state detection is based on
gpioget --chip gpiochip0 GPIO27. - If your desktop environment is not GNOME/Mutter, idle detection in this script may not work.
- The service automatically restarts if it crashes, with a 10-second delay between restarts.
- Logs are sent to the systemd journal and can be viewed with
journalctl --user.
Contributions are welcome.
Please:
- keep the pull requests focused and consistent with the existing style
- update the documentation when the behaviour changes
Licensed under the GNU General Public License v3.0 or later. See LICENSE for details.