LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Laptop and Netbook
User Name
Password
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).

Notices


Reply
  Search this Thread
Old 09-18-2011, 01:49 PM   #1
ElectricZero
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


Hello,
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):
Code:
#!/bin/bash
# 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
 do
  case "$optname" in
   "p")
    #Add more brightness
    #BRIGHT++
    BRIGHT=$(($BRIGHT+1))
    #protect mechanism (BRIGHT must be lower or equal to 15)
     if (($BRIGHT>15))
     then
        BRIGHT=$((15))
     fi
    ;;
   "m")
    #decrease brightness
    #BRIGHT--
    BRIGHT=$(($BRIGHT-1))
    #protect mechanism (BRIGHT must be bigger or equal to 2)
     if (($BRIGHT<2))
     then
        BRIGHT=$((2))
     fi	
    ;;
   "l")
    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"
    ;;
   "h")
     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"
    ;;
  esac
done
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, 07:52 PM   #2
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Australia
Distribution: Devuan
Posts: 5,476

Rep: Reputation: Disabled
hi

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

http://goodies.xfce.org/projects/app...ghtness-plugin

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

hi

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

http://goodies.xfce.org/projects/app...ghtness-plugin
 
  


Reply


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 http://www.linuxquestions.org/questions/slackware-14/brightness-set Z0K4 Linux - Laptop and Netbook 5 09-15-2011 10:09 AM
Backlight Brightness on a Gateway NV5915h jogl_z_8 Debian 0 03-13-2011 08:40 AM
Backlight Brightness on a Gateway NV5915h jogl_z_8 Linux - Laptop and Netbook 11 03-11-2011 02:39 PM
xfce: LCD Brightness plugin?? andrew.46 Slackware 2 10-08-2009 01:36 AM
how to set backlight level unikgila Linux - Software 0 08-12-2008 06:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Laptop and Netbook

All times are GMT -5. The time now is 04:22 PM.

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