12345678910111213141516171819202122232425262728293031323334 |
- #!/bin/sh
- backlight_change(){
- if echo "$1" | grep -E "^\+|([Ii](ncrease)?)$"; then
- xbacklight "+$2"
- elif echo "$1" | grep -E "^\-|([Dd](ecrease)?)$"; then
- xbacklight "-$2"
- elif echo "$1" | grep -E "^\=|([Ss](et)?)$"; then
- xbacklight "=$2"
- else
- echo -a "$3" -h string:x-dunst-stack-tag:BACKLIGHT "Backlight" "Invalid backlight command"
- fi
- level="$(xbacklight -get | grep -Eo '^[0-9]+')"
- dunstify -a "$3" -h string:x-dunst-stack-tag:BACKLIGHT "Backlight" -h int:value:"$level" "$level"
- }
- current=$(xbacklight -get | grep -Eo '^[0-9]+')
- if [ -z "$current" ]; then
- dunstify -a "$1" -h string:x-dunst-stack-tag:BACKLIGHT "Backlight" "Backlight not supported in this system"
- return 1
- elif [ "$current" -gt 50 ]; then
- backlight_change "$2" 10 "$1"
- elif [ "$current" -gt 25 ]; then "$1"
- backlight_change "$2" 5 "$1"
- elif [ "$current" -gt 10 ]; then
- backlight_change "$2" 2 "$1"
- elif [ "$current" -gt 1 ]; then
- backlight_change "$2" "0.5" "$1"
- else
- backlight_change "$2" "0.1" "$1"
- fi
|