daily pastebin goal
28%
SHARE
TWEET

Untitled

a guest May 8th, 2012 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. # helper script for lightum
  4. # (c)2012 Pau Oliva Fora - pof[at]eslack(.)org
  5.  
  6. WM="kde"
  7.  
  8. function get_backlight() {
  9.  
  10.         if [ "$1" == "kde" ]; then
  11.                 val=`dbus-send --session --type=method_call --print-reply --dest=org.kde.Solid.PowerManagement /org/kde/Solid/PowerManagement org.kde.Solid.PowerManagement.brightness |tail -n 1 |awk '{print $2}'`
  12.                 echo "$val"
  13.         else
  14.                 val=`gdbus call --session --dest org.gnome.SettingsDaemon --object-path /org/gnome/SettingsDaemon/Power --method org.gnome.SettingsDaemon.Power.Screen.GetPercentage`
  15.                 val=`echo "$val" |cut -f 2 -d " " |sed -e "s/,)//g"`
  16.                 echo "$val"
  17.         fi
  18.  
  19. }
  20.  
  21. function set_backlight() {
  22.  
  23.         if [ "$1" == "kde" ]; then
  24.                 dbus-send --session --type=method_call --print-reply --dest=org.kde.Solid.PowerManagement /org/kde/Solid/PowerManagement org.kde.Solid.PowerManagement.setBrightness int32:${2} >/dev/null
  25.         else
  26.                 dbus-send --session --print-reply --dest="org.gnome.SettingsDaemon" /org/gnome/SettingsDaemon/Power org.gnome.SettingsDaemon.Power.Screen.SetPercentage uint32:${2} >/dev/null
  27.         fi
  28.  
  29. }
  30.  
  31.  
  32. for backlight in `seq 0 100` ; do
  33.  
  34.         echo -n "SET: ${backlight} GET: "
  35.         set_backlight ${WM} ${backlight}
  36.         sleep 1s
  37.         get_backlight ${WM}
  38.  
  39. done
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top