aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dot_config/sway/executable_brightness-osd.sh
blob: 74d6baa1bf3c0e9c4890c1ec91e1f21e7ae475a2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/sh
# Print brightness percent to wob's fifo to flash a brightness bar.
# Usage: brightness-osd.sh up|down
set -eu

fifo=${XDG_RUNTIME_DIR:-/tmp}/wob.sock

case "${1:-}" in
    up)   brightnessctl set +5% >/dev/null ;;
    down) brightnessctl set 5%- >/dev/null ;;
    *)    echo "usage: $0 up|down" >&2; exit 2 ;;
esac

cur=$(brightnessctl g)
max=$(brightnessctl m)
printf '%d\n' "$(( cur * 100 / max ))" >"$fifo"