123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- version=1.0
- step=10
- check_installed()
- {
- if [ ! -f /bin/notify-send-improved -a -f /bin/xbacklight ]; then
- echo "Notify-send-improved and/or xbacklight not present."
- echo "Please install them."
- exit 2
- fi
- }
- if [[ "$#" -ge 2 ]]; then
- echo "Usage: $0 {-v, --version | -h --help}"
- exit 2
- elif [[ $# -le 1 ]]; then
- case $1 in
- -v | --version)
- echo "$0 - Version $version"
- exit 0
- ;;
- -h | --help)
- echo "- v, --version Display current version"
- echo "-h, --help Display this message"
- echo "up Increase brightness by $step%"
- echo "down Decrease brightness by $step%"
- exit 0
- ;;
- "up")
- check_installed
- xbacklight -steps 1 -time 0 -inc $step
- ;;
- "down")
- check_installed
- xbacklight -steps 1 -time 0 -dec $step
- ;;
- *)
- echo "Usage: $0 {up|down| -v, --version | -h, --help}"
- exit 2
- esac
- fi
- brightness=`xbacklight | awk '{printf("%d\n", $0+=$0<0?0:0.9)}'`
- brightnessicon="/usr/share/icons/Adwaita/32x32/status/display-brightness-symbolic.symbolic.png"
- if [ ! -f "/tmp/brightness_notification_id.dat" ]; then
- notification_id="0"
- notification_id=$(notify-send-improved "Brightness Control" -i $muteicon --print-id -t 1000 "Brightness: $brightness" | tee /dev/tty)
- else
- notification_id=`cat /tmp/volume_notification_id.dat`
- notify-send-improved "Brightness Control" -i $brightnessicon --print-id --replace=$notification_id -t 1000 "Brightness: $brightness\%"
- fi
- echo "${notification_id}" > /tmp/brightness_notification_id.dat
|