Persistent display brightness on OpenBSD with rc and wsconsctl
1 April 2022

Laptop users of OpenBSD know that there's no built-in functionality for keeping the display's brightness persistent across reboots. It's possible to use rc(8) and wsconsctl(8) to write the display's brightness setting to a file on shutdown and read it during startup.

We'll start by creating /etc/rc.shutdown (if it doesn't exist) and add the following to it:

/etc/rc.shutdown
#!/bin/sh wsconsctl display.brightness | cut -f2 -d= > /var/brightness
and make it executable:
# chmod +x /etc/rc.shutdown
On shutdown, the value of display.brightness from wsconsctl gets written to /var/brightness.

Next, create /etc/rc.local (if it doesn't exist) and add the following:

/etc/rc.local
#!/bin/sh wsconsctl display.brightness=$(cat /var/brightness)
Make it executable:
# chmod +x /etc/rc.local

During startup, wsconsctl will set display.brightness to the value in /var/brightness.