Xfce Style Changing With Brightness Buttons Hack


urjaman

"I Know. We're going for a ride."
Joined
Jan 6, 2009
Messages
1,111
Age
34
Location
Finland
Website
urja.dev
Ok. so i usually go with Xfce-dusk, but i really wont cut it in the sunlight, etc. Luckily it has the acceptable bright version called Xfce-dawn. Here we go with files (which you will read and understand and atleast replace my username with yours, ok?):

/usr/bin/dusk.sh
Code:
#!/bin/sh
export DISPLAY=":0.0"
export XAUTHORITY='/home/urjaman/.Xauthority'
PID=$(pidof xfce4-panel)
export $(cat /proc/$PID/environ | xargs -0 -n1 echo | grep ^DBUS_SESSION_BUS_ADDRESS=)
xfconf-query -c xsettings -p "/Net/ThemeName" -s Xfce-dusk
/usr/bin/dawn.sh is identical, except that the theme name is Xfce-dawn (i wanted these as command line shortcuts, too)

Modified /usr/pandora/scripts/op_bright_up.sh:
Code:
#!/bin/bash
cur=$(cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness);
if [ "$cur" == 54 ]; then
	su urjaman -c /usr/bin/dawn.sh
fi
echo $(($cur+10)) > /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness

Modified /usr/pandora/scripts/op_bright_down.sh:
Code:
#!/bin/bash
cur=$(cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness);
if [ $cur -lt 10 ]; then
	su urjaman -c /usr/bin/dusk.sh
fi
echo $(($cur-10)) > /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness
 
When you try to increase brightness over max, xfce appearance style is changed to Xfce-dawn (normal bright theme). When trying to decrease at below 10, set style to Xfce-dusk (very dark theme). The hackiest part was getting the user dbus session name available when originally being launched as root. It reads xfce4-panels environment for that. I dont want to write a thorough guide, no time and propably not many people want this. Just dropped my hack here if for some reason somebody would be inspired by it.

I also thought of adding cron calls to these scripts to change the theme based on time of day.
 
Do we have cron in the firmware?

It would be great if this adjusted the gamma/colour brightness of the display. That way, it would work nicely for all themes.
 
Back
Top