2020-10-10 21:33:28 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# You can call this script like this:
|
|
|
|
# $./dunst-backlight.sh up
|
|
|
|
# $./dunst-backlight.sh down
|
|
|
|
|
|
|
|
get_light() {
|
2020-10-10 21:38:20 +02:00
|
|
|
xbacklight -get | cut -f1 -d"."
|
2020-10-10 21:33:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
send_notification() {
|
|
|
|
light=$(get_light)
|
|
|
|
# Make the bar with the special character ─ (it's not dash -)
|
|
|
|
# https://en.wikipedia.org/wiki/Box-drawing_character
|
|
|
|
bar=$(seq -s "─" $(($light/ 5)) | sed 's/[0-9]//g')
|
|
|
|
# Send the notification
|
2020-10-10 22:29:40 +02:00
|
|
|
dunstify -i whitebalance -r 2489 -a backlight-script -u low " $bar "
|
2020-10-10 21:33:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
up)
|
|
|
|
# Increase backlight
|
2020-10-10 22:33:16 +02:00
|
|
|
xbacklight -inc 10 > /dev/null
|
2020-10-10 21:33:28 +02:00
|
|
|
send_notification
|
|
|
|
;;
|
|
|
|
down)
|
|
|
|
# Decrease backlight
|
2020-10-10 22:33:16 +02:00
|
|
|
xbacklight -dec 10 > /dev/null
|
2020-10-10 21:33:28 +02:00
|
|
|
send_notification
|
|
|
|
;;
|
|
|
|
esac
|