configs/arch-config/scripts/dunst/dunst-backlight.sh

41 lines
1.1 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
2020-10-10 21:33:28 +02:00
# You can call this script like this:
# $./dunst-backlight.sh up
# $./dunst-backlight.sh down
get_light() {
#xbacklight -get | cut -f1 -d"."
xbacklight -get
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')
2020-10-10 21:33:28 +02:00
# Send the notification
dunstify -i whitebalance -r 2489 -a backlight-script "$light $bar "
2020-10-10 21:33:28 +02:00
}
case $1 in
up)
# Increase backlight
xbacklight -inc 10 >/dev/null
#xbacklight -inc 10% > /dev/null # legacy xorg-xbacklight
send_notification
#backlightraw=$(xbacklight -get)
#backlight=${backlightraw::-8}
#xbacklight -set "${backlight}0"
;;
2020-10-10 21:33:28 +02:00
down)
# Decrease backlight
xbacklight -dec 10 >/dev/null
#xbacklight -dec 9% > /dev/null # legacy xorg-xbacklight
send_notification
#backlightraw=$(xbacklight -get)
#backlight=${backlightraw::-8}
#xbacklight -set "${backlight}0"
;;
2020-10-10 21:33:28 +02:00
esac