Turning off Radeon LCD backlight when GNOME screensaver is activated

I wrote a quick and dirty script that turns on and off ATI Radeon LCD backlight by monitoring DBUS events to detect the activation and deactivation of GNOME screensaver. It requires the radeontool package to be installed and it needs to be set with suid flag (i.e. chmod u+s /usr/sbin/radeontool). Please feel free to launch the following script when your GNOME session starts:

#!/bin/sh
if [ "x`pgrep -of 'radeon-watch'`" != "x$$" ]; then
exit 1
fi
radeontool dac on
radeontool light on
{
dbus-monitor --session --monitor "type='signal',path='/org/gnome/ScreenSaver',interface='org.gnome.ScreenSaver'" | while read -r EVT; do
echo "$EVT" | grep -qi "SessionIdleChanged"
if [ "$?" = '0' ]; then
read -r EVT_VAL
echo "$EVT_VAL" | grep -qi "true"
if [ "$?" = '0' ]; then
radeontool dac off
radeontool light off
else
radeontool dac on
radeontool light on
fi
fi

echo "$EVT" | grep -qi "AuthenticationRequestBegin"
if [ "$?" = '0' ]; then
radeontool dac on
radeontool light on
fi

echo "$EVT" | grep -qi "AuthenticationRequestEnd"
if [ "$?" = '0' ]; then
radeontool dac off
radeontool light off
fi
done
} &

Please note that I tested this script with my old ThinkPad X31, so you might not need this script if you have the recent laptop or you are using other video chipset.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.