Yellow Rabbit

Adjusting the Brightness, What Did Not Happen

The Keys for Adjusting the Screen Brightness - Acer C720 Laptop, BSD

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 brightness-inc.sh increases the brightness:


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

The second script brightness-dec.sh reduces:


#!/bin/sh
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
"brightness-dec.sh"
  F6

"brightness-inc.sh"
  F7