autosuspend: Automatically Suspending a Server on Inactivity
A few months ago I sold my existing basic Synology NAS and built my own one based on a power-efficient Intel CPU inside a mini ITX system with a usual Linux as the operating system. This provided me with a lot more flexibility and e.g. possibilities to encrypt my data properly. One thing I needed for this custom solution was a daemon to suspend the system in case of inactivity to further reduce the power consumption. I found a few existing scripts online, started using one of them, but soon had to modify it deeply until it was general enough to suit my needs. Today, I finally took the time to clean up the last issues in the code base and the autosuspend project is now available on Github.
autosuspend periodically checks a running Linux system for certain conditions which shall prevent the system from going to sleep. Such conditions can be logged in users, external TCP connections, music playing on MPD, X11 activity etc. In case the configured checks did not indicate activity for a certain amount of time, the system is automatically suspended. You should configure Wake-on-LAN for being able to bring the system back up in case you need it again.
autosuspend is implemented in Python 3, all checks are configurable via configuration file and custom checks can be added easily. The repository includes a systemd unit which I use to run the daemon on my Archlinux setup. For Archlinux, there is also a PKGBUILD on AUR.
I'd be glad if someone finds this script useful, too. In case of issues, please use the issue tracking in the Github project.