Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Laptop and Netbook
User Name
Linux - Laptop and Netbook Having a problem installing or configuring Linux on your laptop? Need help running Linux on your netbook? This forum is for you. This forum is for any topics relating to Linux and either traditional laptops or netbooks (such as the Asus EEE PC, Everex CloudBook or MSI Wind).


  Search this Thread
Old 09-18-2011, 02:49 PM   #1
LQ Newbie
Registered: Sep 2011
Location: Liberec, Czech Republic
Distribution: Fedora 15 + XFCE spin
Posts: 1

Rep: Reputation: Disabled
Script to set-up brightness of backlight in XFCE

I have written script to set-up brightness of backlight in XFCE (it will probably works with any linux distribution and X). It is only editing number in /sys/class/backlight/acpi_video0/brightness. This script works good in command line, it will decrease/increase brightness by 1 degree, but I have different problem with that script.

When I make shortcuts in XFCE (Applications-> preferences-> keyboard -> keyboard shortcuts tab) and associate commands bright -p / bright -m with keys for changing brightness on my laptop it works properly too, but bad things is, that on one press of key, it decrease or increase brightness by 2 degrees. In other words, this script is executed twice on one press of key. How to execute it only once on one press of key?

PS: I know, in XFCE exist plugin for regulating backlight brightness, but I didn't found, how to drive it from command line (for keyboard) and it forgets last set value, so after reboot, backlight is back on maximum.

My script looks like that (If it help):
# Script for changing backlight brightness in /sys/class/backlight/acpi_video0/brightness
# can take values 0-15, in real (my notebook) works only values 2-15

#IMPORTANT: you must have writing rights to /sys/.../brightness (I must solute it with visudo or something like that...)
#IMPORTANT: for proper work after reboot must exist directory .bright in your home directory and file last_bright in .bright directory 

#reads content of brightness and save it into variable
BRIGHT=$(cat /sys/class/backlight/acpi_video0/brightness)

while getopts "pmlh" optname
  case "$optname" in
    #Add more brightness
    #protect mechanism (BRIGHT must be lower or equal to 15)
     if (($BRIGHT>15))
    #decrease brightness
    #protect mechanism (BRIGHT must be bigger or equal to 2)
     if (($BRIGHT<2))
    echo "Loading last value of brightness."
    #Load last value, saved in file last_bright
    BRIGHT=$(cat $HOME/.bright/last_bright)
    echo "Poslední hodnota bright je $BRIGHT"
     echo "Help: "
     echo "-p	Increase brightness"
     echo "-m	Decrease brightness"
     echo "-l	Load last brightness value"
     echo "-h	This help"
     echo "Programmed by: ElectricZero"
     echo "Unkonwn argument, try bright -h for help"
    # Should not occur
    echo "Unknown error while processing options"
echo "Brightness set on $BRIGHT"
#Save variable BRIGHT into file brightness
echo $BRIGHT > /sys/class/backlight/acpi_video0/brightness
#Save variable BRIGHT into file last_bright
echo $BRIGHT > $HOME/.bright/last_bright
Old 09-19-2011, 08:52 PM   #2
LQ 5k Club
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,787

Rep: Reputation: Disabled

try installing the xfce4-goodies package which will give you a slider

---------- Post added 20-09-11 at 08:52 ----------


try installing the xfce4-goodies package which will give you a slider


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Brightness set to zero: moved to Z0K4 Linux - Laptop and Netbook 5 09-15-2011 11:09 AM
Backlight Brightness on a Gateway NV5915h jogl_z_8 Debian 0 03-13-2011 09:40 AM
Backlight Brightness on a Gateway NV5915h jogl_z_8 Linux - Laptop and Netbook 11 03-11-2011 03:39 PM
xfce: LCD Brightness plugin?? andrew.46 Slackware 2 10-08-2009 02:36 AM
how to set backlight level unikgila Linux - Software 0 08-12-2008 07:54 AM > Forums > Linux Forums > Linux - Laptop and Netbook

All times are GMT -5. The time now is 10:48 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration