Thanks for this example! I got the Waveshare Magic Mirror a few days ago and was looking for a solution to dim the backlight.
I’m using xscreensaver
to blank the screen after 2 minutes and used the ddcutil
command to dim the backlight.
Here is the script I’m using:
#!/bin/sh
process() {
while read line; do
case "$line" in
UNBLANK*)
sudo ddcutil setvcp 10 100
;;
BLANK*)
sudo ddcutil setvcp 10 1
;;
esac
done
}
xscreensaver-command -watch | process
I use xscreensaver-command -watch
to get the state changes, see https://www.jwz.org/xscreensaver/man3.html