# KDE brightness control Samsung laptop

## Martux

Hi!

I have a Samsung R780 laptop and am wondering if it is possible to control the brightness recently.

I have the Samsung laptop extras compiled in the kernel but this model doesn't seem to be supported so far. Is there any change on this, any workaround? Thank you.

----------

## Yttrium

EDIT: I just found out that you don't have an Intel GPU. I am pretty sure this doesn't work for AMD/Nvidia GPUs. Anyway this might be useful for other Samsung Laptop users, so I decided not to delete the answer.

======================================================================

Hi,

here is a shell script that I use as a workaround on my NC10 (Pineview/Intel graphics). Since you're using KDE you probably want to use kdialog instead of notify-send.

```
#!/bin/bash

DEVICE=00:02.0

SETPCI="sudo /usr/sbin/setpci"

AMOUNT=15

MIN=15

DEFAULT_DEC=120

DEFAULT=$(echo "ibase=10; obase=16; print $DEFAULT_DEC" | bc)

#get current brightness in hex and convert to decimal

var1=$($SETPCI -s $DEVICE F4.B)

var1d=$((0x$var1))

case "$1" in

       up)

         var2=`echo "ibase=10; obase=16; a=($var1d+$AMOUNT);if (a<255) print a else print 255" | bc`

         #echo "$0: increasing brightness from $((0x$var1)) to $((0x$var2))"

         notify-send -t 500 "Brightness level $((0x$var2))"

         $SETPCI -s $DEVICE F4.B=$var2

         ;;

       down)

            var2=`echo "ibase=10; obase=16; a=($var1d-$AMOUNT);if (a>$MIN) print a else print $MIN" | bc`

            #echo "$0: decreasing brightness from $((0x$var1)) to $((0x$var2))"

            $SETPCI -s $DEVICE F4.B=$var2

            notify-send -t 500 "Brightness level $((0x$var2))"

            ;;

       set)

            var2=`echo "ibase=10; obase=16; a=$2;if (a>$MIN) print a else print $MIN" | bc`

            echo -e " \e[1;32m*\e[0m Setting brightness level to $((0x$var2))"

            $SETPCI -s $DEVICE F4.B=$var2

            ;;

       get)

            echo "$0: current brightness is $var1d"

            ;;

       toggle)

               if [ $var1d -eq 0 ] ; then

                  #echo "toggling up"

                  $SETPCI -s $DEVICE F4.B=$DEFAULT

                  notify-send -t 1000 "Brightness level $((0x$DEFAULT))"

               else

                  #echo "toggling down"

                  $SETPCI -s $DEVICE F4.B=0

               fi

               ;;

       *)

               echo "usage: $0 {up|down|set <val>|get|toggle}"

               ;;

esac

exit 0

```

sudoers should look like

```
$USER ALL=(root) NOPASSWD: /usr/sbin/setpci -s 00\:02.0 F4.B

$USER ALL=(root) NOPASSWD: /usr/sbin/setpci -s 00\:02.0 F4.B=?

$USER ALL=(root) NOPASSWD: /usr/sbin/setpci -s 00\:02.0 F4.B=??

```

In KDE, you can map the FN+UP and FN+DOWN keys to "/path/to/script.sh up" resp. "/path/to/script.sh down"

----------

## dangbarry

hey Yttrium, 

The NC10 is a great netbook, one of my best buys ever.  There is a better way to configure the keys..  have a look into xbindkeys, it integrates with the normal xorg environment so it works for all vm. It does the fn keys for the NC10.   Notify-send and kdialog,   no, just no..   

you'll find it here: 

http://www.nongnu.org/xbindkeys/xbindkeys.html

& here: 

http://www.gentoo-wiki.info/HOWTO_Use_Multimedia_Keys#Window_manager_hotkey_support

oh and for the NC10 use this ~/.xbindkeysrc for your volume and brightness 

"amixer sset Master 2+ &"

    m:0x0 + c:176

"amixer sset Master 2- &"

    m:0x0 + c:174

#"amixer sset Master 0 &"

"amixer sset Master toggle &"

    m:0x0 + c:160

#"sudo pm-suspend"

#    m:0x0 + c:223

"xbacklight +10"

    m:0x0 + c:233

"xbacklight -10"

    m:0x0 + c:232

----------

