Skip to content

Instantly share code, notes, and snippets.

@uwabami
Created May 22, 2017 04:11
Show Gist options
  • Select an option

  • Save uwabami/ede00be83752c3993922c863e72fb3cb to your computer and use it in GitHub Desktop.

Select an option

Save uwabami/ede00be83752c3993922c863e72fb3cb to your computer and use it in GitHub Desktop.
xbacklight っぽく gsd-backlight-helper を呼び出すシェルスクリプト
#!/bin/sh
PKEXEC=/usr/bin/pkexec
GSD=/usr/lib/gnome-settings-daemon/gsd-backlight-helper
GETOPT=/usr/bin/getopt
OPT=`getopt -a -o sg --long set, --long get -- "$@"`
show_usage(){
echo "Usage $0 [--get] [--set number]" 1>&2
}
if [ $? != 0 ]; then
show_usage
exit 0
fi
eval set -- "$OPT"
while true
do
case "$1" in
-g | --get )
echo `$PKEXEC $GSD --get-brightness`
shift
;;
-s | --set )
MAXVAL=`$PKEXEC $GSD --get-max-brightness`
if [ $3 -gt $MAXVAL ]; then
echo "brightness value is greater than MAX value"
break
else
$PKEXEC $GSD --set-brightness $3
fi
shift
;;
--)
shift
break
;;
*)
show_usage
exit 0
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment