iMac brightness setting script

I wrote a simple script to adjust the brightness om my iMac 27" running Ubuntu 11.10 oneiric. The script is using the gsd-backlight-helper that also available in Ubuntu precis 12.10 so I suppose this also works in 12.10. (let me know)

My solution is to add two brightness icons on the gnome-panel. One for brightness-up and one for brightness-down. (see screenshot)

Copy the script imac-brightness.sh in your /home/USER/ directory

    #!/bin/bash
   
    # get the brightness as it is now
    BRIGHTNESS=$(pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper --get-brightness)
   
    # Get the maximum possible brightness to set
    MAXBRIGHTNESS=$(pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper --get-max-brightness )
   
   
    # If the user want to set the brightness higher than now the
    # script is calles with the argument --up
    # ./imac_brightness.sh --up
    if [ $1 == "--up" ];
       then
    # Check if we got more brightness steps left to raise the brightness
    if [ $BRIGHTNESS -lt $MAXBRIGHTNESS ] ;
    then
    pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper --set-brightness $(($BRIGHTNESS + 1 ));
    fi
    fi
   
    # If the user want to set the brightness lower than now the
    # script is calles with the argument --down
    # ./imac_brightness.sh --down
    if [ $1 == "--down" ]
       then
     # Check if the brightness is't  as low as 1.
     # We won't go lower than 1
     if [ $BRIGHTNESS -gt 1 ] ;
    then
        pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper --set-brightness $(($BRIGHTNESS - 1 ));
     fi
    fi

Make the scrip executable

chmod 755 ./imac-brightness.sh

Copy the brightness-icons in your home directory (or wherever you want, as long if you know where you put them)

Brightness-down icon

Brightness-up icon

Now add the icons to the gnome panel (Mousepointer on the gnome-panel and press left Alt key + right mouse button)
**For Brightness DOWN**
- add to panel
- Custom Application Launcher
- Name: Brightness Down
- Command: /home/USER/imac_brightness.sh --down
- Select the Brightness Down icon

**For Brightness UP**
- add to panel
- Custom Application Launcher
- Name: Brightness Up
- Command: /home/USER/imac_brightness.sh --up
- Select the Brightness Up icon

Now you got two Icon on your gnome-panel. Simply click the Up or Down to adjust the brightness.

Post new comment
The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.