aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dot_config/sway/executable_brightness-osd.sh
diff options
context:
space:
mode:
Diffstat (limited to 'dot_config/sway/executable_brightness-osd.sh')
-rw-r--r--dot_config/sway/executable_brightness-osd.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/dot_config/sway/executable_brightness-osd.sh b/dot_config/sway/executable_brightness-osd.sh
new file mode 100644
index 0000000..74d6baa
--- /dev/null
+++ b/dot_config/sway/executable_brightness-osd.sh
@@ -0,0 +1,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"