Adjusting the Brightness, What Did Not Happen

197 words | 2014-12-26

The second way is to create a special device, reading from it returns the current backlight level, and writing into it changes this level. And such a device was created. This required much more intervention in the code, including changing several Makefile, the system configuration file (sys/conf/options), adding a directory to the source files of the device.

The device worked, but it did not help third-party utilities to see the presence of the backlight adjustment. The fact is that for these utilities, the presence of the /sys/class/backlight /something directory was critical, which contained special files of actual_brightness, brightness, max_brightness, subsystem/, uevent, bl_power, device/, power/ and the like.

This is the so-called Linux-sysfs, which is not (or I did not find) in DragonFly BSD. To create its analog for adjusting the level of illumination … perhaps overkill. So instead I did:

Binding of the backlight adjustment keys

The first script increases the brightness:

LVL=`/sbin/sysctl -n hw.backlight_level`
/sbin/sysctl hw.backlight_level=$(( ${LVL} + 50 ))

The second script reduces:

LVL=`/sbin/sysctl -n hw.backlight_level`
/sbin/sysctl hw.backlight_level=$(( ${LVL} - 50 ))

In the file .xbindkeysrc we specify the binding of scripts to the keys:

# brightness