aboutsummaryrefslogtreecommitdiff
path: root/.config/eww/scripts/brightnesscontrol
diff options
context:
space:
mode:
authorJustine Smithies <justine@smithies.me.uk>2024-11-08 20:48:58 +0000
committerJustine Smithies <justine@smithies.me.uk>2024-11-08 20:48:58 +0000
commitc2fbc4d1717864a0055592e0b73d71c010e8686c (patch)
tree76e5bf50cc0f9c1b83f474740a8015d7f4e0ef26 /.config/eww/scripts/brightnesscontrol
parentb9d24b3b6bdaed04fab07d9150c51d4f0f7a5c7d (diff)
Initial commit
Diffstat (limited to '.config/eww/scripts/brightnesscontrol')
-rwxr-xr-x.config/eww/scripts/brightnesscontrol39
1 files changed, 39 insertions, 0 deletions
diff --git a/.config/eww/scripts/brightnesscontrol b/.config/eww/scripts/brightnesscontrol
new file mode 100755
index 0000000..1e8ea9f
--- /dev/null
+++ b/.config/eww/scripts/brightnesscontrol
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+
+# You can call this script like this:
+# brightnessControl up
+# brightnessControl down
+
+# Script inspired by these wonderful people:
+# https://github.com/dastorm/volume-notification-dunst/blob/master/volume.sh
+# https://gist.github.com/sebastiencs/5d7227f388d93374cebdf72e783fbd6a
+
+function send_notification {
+ icon="/usr/share/icons/Adwaita/symbolic/status/daytime-sunrise-symbolic.svg"
+ brightness=$(backlight -q)
+ # Make the bar with the special character ─ (it's not dash -)
+ # https://en.wikipedia.org/wiki/Box-drawing_character
+ bar=$(seq -s "─" 0 $((brightness / 10 )) | sed 's/[0-9]//g')
+ # Send the notification
+ fyi -i "$icon" --hint=string:x-canonical-private-synchronous:brightness -u normal "$bar $brightness"
+}
+
+case $1 in
+ up)
+ backlight + 4
+ backlight > ~/.cache/brightness
+ send_notification
+ # canberra-gtk-play -i audio-volume-change
+ ;;
+ down)
+ backlight - 4
+ backlight > ~/.cache/brightness
+ send_notification
+ # canberra-gtk-play -i audio-volume-change
+ ;;
+ *)
+ brightness=$(backlight -q)
+ icon=""
+ printf "%s" "$icon $brightness" "%"
+ ;;
+esac