udev, systemd, laptop, power management and backlight brightness

Sat 13 December 2014

[caption id="" align="alignright" width="218" class="zemanta-img"]Broken laptop computer Laptop problem (Photo credit: Wikipedia)[/caption]

My two problems with my laptop are the following:

  1. I want to control the backlight brihtness of my screen even if I don't start the graphical desktop (i.e. work with tty)
  2. I want to be able to suspend to ram and hibernate when needed (e.g. in a train station during the connection) but I don't want my laptop to suspend to ram when the battery is almost depleted (mainly because the sensor telling it's almost depleted is not really accurate).

I use archlinux with systemd and udev.

Screen brightness

The brighness depend of the GPU controller. Mine is an intel. All files are in /sys/class/backlight/intel_backlight/.
You may adapt this for non-intel GPU
The filenames are quite explicit:
$ ls /sys/class/backlight/intel_backlight/
actual_brightness  bl_power  brightness  device@  max_brightness  power/  subsystem@  type  uevent
brighness is a one-line file containing only a number. You can ovrewrite this by almost any number between 0 and the one in max_brightness.
To quickly set the maximal brightness:cat max_brightness > brightness.

Suspend to ram and hybernante

The power management is well documented in the archlinux wiki. If you want to add costum rules for your power management, just follow the appropriate wiki page.

Nevertheless it is hard to deactivate rules that are not explicitly described in the config files. The config files include the one for udevd, systemd, acpid, and upower. The solution I found is to disable the upower deamon: systemctl disable upower.service. Note that it may not be enough as upower can be reactivated by other deamon and thus must be explicitly stop again.

(non-)Related articles

Related articles (or not):

Category: how to Tagged: ArchLinux Laptop Linux Systemd Udev tools