Hypersomnia and Linux Power Managers

Linux Power Managers

Is it too much to ask for a program that can handle dimming of the screen, turning off the screen, launching a lockscreen, and putting the system to sleep after a period of user idleness while not pulling in an entire desktop-environment through its dependencies and all with sane defaults? Apparently, yes.


What I need in a power manager:

  • Dim the screen to notify me that my session is about to be locked.
    • But not when I’m watching a video.
    • And not when there’s a file downloading. (network activity)
    • And lastly, not when I’m compiling something. (high CPU load)
  • Turn the screen off if I’m not there to hit my keyboard to cancel the notifier.
  • Put my system to sleep a couple of minutes after that.
  • Always launch my lockscreen before sleeping.

Possible Solutions

Power manager for XFCE. Most capable and feature rich, however, it cannot launch other screenlockers such as i3lock or xsecurelock.

LXQt’s power manager. The idleness watcher only allows for one timer, meaning you need to choose between your system sleeping or locking. Has less features and same limitations as xfce4-power-manager.

A versatile autolocker. Completely manual, you are required to provide the functionality other than timing. Rather annoying to configure and requires constant tinkering to get it perfect for a short period of time. Only a maximum of three timers can be set: -notify, -time, and -killtime. The limitation becomes an issue if you want to do more than just notifying (without a canceller), locking, and sleeping.

Originally written as a replacement to xautolock, xidlehook went up and beyond xautolock’s functionality by including unlimited timers. Also includes cancellers and inhibitor functionality.

Launches lockscreen on events like lid closing and X screensaver’s timer set with xset. Can be used to aleviate some of xfce4-power-manager and lxqt-powermangement’s shortcomings.

My Solution

A completely desktop-environment agnostic solution to power management. It is written in Bash to be easily customizable and uses a simple C program timepiece to efficiently monitor idleness.

As I’ve tried most of the other possible solutions which couldn’t scratch my itch, I came to the conclusion that I would have to create my own solution.

I expanded on the basic requirements of notifying, locking, and system sleeping by adding things like inhibitors, notification options, hooks, and more – all with minimal to no configuration, thanks to sane defaults.

One particularly great feature is pausing, set the timers to not activate for a period of time. Don’t want the computer to sleep because you have a virtual machine running? hypersomnia --pause 60 sleep, now it won’t sleep for an hour. Although the CPU usage inhibitor may be better off for a case like that, it’s still an option.

There are over 30 variables you can change (but let me stress again, sane defaults) to make it just right for you.

Finally, my itch has been scratched.