/Main_Page

::You must have ninja focus to complete your mission::NinjaFocus::

DBUS Backlight Brightness

Views:


The bios on my samsung n130 doesn't handle the backlight brightness keys, so linux needs to be told how to do it. The ArchLinux wiki has a script to Control brightness on a samgung n140 but that requires root privileges. You can set it sudo to not ask for a password but it's a bit of a hack IMHO. The xbacklight command could be used but I don't find that covers the full range of brightness level the backlight can display (this might change because xbacklight only recently started working for N1[34]0s.

DBUS seems like a much cleaner solution so I wrote this script to change backlight brightness, which can be called from xbindkeys.

/usr/local/bin/brightness

#!/bin/bash
#
#
# Increases brightness 
#
# Written by Kieran Whitbread 2010
#
function getBrightness() {
    dbus-send \
    --print-reply \
    --system \
    --dest=org.freedesktop.Hal  \
    /org/freedesktop/Hal/devices/computer_backlight \
    org.freedesktop.Hal.Device.LaptopPanel.GetBrightness | \
    tail -1 | \
    awk '{print $2}'
}
function setBrightness() {
    dbus-send \
    --print-reply \
    --system \
    --dest=org.freedesktop.Hal  \
    /org/freedesktop/Hal/devices/computer_backlight \
    org.freedesktop.Hal.Device.LaptopPanel.SetBrightness \
    int32:$1 #2&>1 > /dev/null
}
max=$(cat /sys/class/backlight/acpi_video0/max_brightness)

current=$(getBrightness)

case $1 in
    up)
        setBrightness $(( $current + 1 ));;
    down)
        setBrightness $(( $current - 1 ));;
    max|full)
        setBrightness $max;;
    min)
        setBrightness 0;;
esac

DBUS permissions need to be added for the user's you want to be allowed to change the brightness. Create a group (or choose an existing one) and add the following snippet to your hal policies.

  <policy group="xusers">
    <allow send_destination="org.freedesktop.Hal"
    	   send_interface="org.freedesktop.Hal.Device.KeyboardBacklight"/>
  </policy>

Main Menu

Personal tools

Toolbox