Thursday, February 20, 2014

Suspend when Idle

E's power management features work well for the most part, but if you want your Chromebook to sleep when idle while working in the console (not running X), you're out of luck. One solution is powernap, which makes use of various "monitors" to determine whether the system is idle or not.

It doesn't work out of the box, but only a few simple edits are required.

After installing the package, first go edit /etc/default/powernap. You'll see these lines:

# start powernap at boot [yes|no]
START=no

Just change no to yes and save the file.

Next, head on over /etc/powernap. You'll see a file here called config. Open that up, and head over to the line that reads this:

[ConsoleMonitor] 
ptmx = y

For whatever reason, /dev/ptmx doesn't work for monitoring console activity in Chrubuntu, so change this to /dev/pts, so it reads:

[ConsoleMonitor]
pts = yes

[ UPDATE: You actually need to edit the powernap python script itself to get this to work. Head on over to /usr/share/pyshared/powernap/monitors/ConsoleMonitor.py and open it up in your favorite text editor. Skip down to line 38 and change the words "keyboard" and "mouse" to "cros_ec_keyb" and "cyapa" respectively. Then sudo service powernap restart. Note that these device names may vary depending on your version of the kernel / Ubuntu, you can see the full device list in /proc/interrupts. It may not be obvious which device is which.)

You'll probably also want ACTION_SECONDS from the default 30 to something more reasonable like 300 (5 minutes) once you're sure everything is working.

Powernap supports a sort of escalation, but if you just simply want your Chromebook to sleep when idle, you can change ACTION_METHOD from 0 (powersave) to 1 (suspend), and it will sleep immediately after ACTION_SECONDS expires.

The processor load monitor works fine when set to the default, but there's plenty of other monitors you can configure (disk activity, network activity, etc.) that ship inactive if you want more advanced idle detection.

Reboot to be safe, or you can try restarting the powernap service using sudo service powernap restart.

Using this method, sleep/wake works perfectly fine from within X (with Enlightenment's auto blanking turned off) or the console alike. I might use the same technique for auto dimming, because I've found E's built-in auto dimming feature to be somewhat flakey.

No comments:

Post a Comment