If you like me have a machine running Linux OS and want to be able to persist your screen’s brightness setting, here is a small script that does the trick. (I don’t know if that feature lacks only in Ubuntu running in a Dell XPS 15 l502x or common to all Linux laptops)
Initially the problem is that once you reboot the machine, you lose the brightness setting and you have to manually adjust again. Annoying!
With the following instructions, you’ll be able to fix that. Tested in Ubuntu 13.10.
Copy these following three scripts in your Desktop folder (Or in the same folder) and give them execution permission:
RESET script (brightness-reset.sh):
#!/bin/bash # Author: Hanine HAMZIOUI ALMADANY <email@example.com> # This script sets the brightness in Ubuntu as it is not persistent upon reboot # In order to manually execute these commands below, the user must be root # Brightness values are integers that range from 0 to 15 DEFAULT_BRIGHTNESS=7 CUSTOMBRIGHTNESS="$HOME/brightness/last_brightness" if [ -f $CUSTOMBRIGHTNESS ];then echo $(cat $CUSTOMBRIGHTNESS) > /sys/class/backlight/acpi_video0/brightness else echo $DEFAULT_BRIGHTNESS > /sys/class/backlight/acpi_video0/brightness fi exit 0
Brightness RUN (brightness-run.sh)
#!/bin/bash # Persist Brightness value in Ubuntu 13.10 # Author Hanine HAMZIOUI ALMADANY <firstname.lastname@example.org> if [ -f "brightness-reset.sh" ]; then sudo cp -v brightness-reset.sh /etc/init.d/ && sudo chmod +x /etc/init.d/brightness-reset.sh else echo "brightness-reset file does not exist, it must be in the same folder. Terminating..."; exit 0; fi if [ -f "brightness-save.sh" ]; then sudo cp -v brightness-save.sh /etc/init.d/ && sudo chmod +x /etc/init.d/brightness-save.sh else echo "brightness-save file does not exist, it must be in the same folder. Terminating..."; exit 0; fi sudo ln -s /etc/init.d/brightness-save.sh /etc/rc0.d/K10brightness-save # Brightness SAVE Symbolic link to RC 0 sudo ln -s /etc/init.d/brightness-save.sh /etc/rc6.d/K10brightness-save # Brightness SAVE Symbolic link to RC 6 rawfile=`cat /etc/rc.local | grep "/etc/init.d/brightness-reset.sh"` if [ -z "$rawfile" ]; then sudo sed -e 's/exit 0//g' -i /etc/rc.local sudo echo "#Reset screeen brightness" >> /etc/rc.local sudo echo "/etc/init.d/reset-brightness.sh" >> /etc/rc.local sudo echo "exit 0" >> /etc/rc.local else echo "RC.LOCAL file is already customized to reset brightness at startup...If you think otherwise, do it manually again!" fi exit 0;
BRIGHTNESS Save (brightness-save.sh)
#!/bin/bash # Author: Hanine HAMZIOUI ALMADANY <email@example.com> # Target: Ubuntu 13.10 and below # Script that saves the last brightness value used CUSTOMBRIGHTNESS="$HOME/brightness/last_brightness" mkdir -p $(dirname $CUSTOMBRIGHTNESS) cat /sys/class/backlight/acpi_video0/brightness > $CUSTOMBRIGHTNESS exit 0;
chmod +x ~/Desktop/brightness-*
And finally; from your terminal again:
You will be prompted for your user password.
Now adjust brightness ti a certain value and reboot. 😉