aboutsummaryrefslogtreecommitdiff
path: root/.config/eww/scripts/brightnesscontrol.sh
diff options
context:
space:
mode:
authorJustine Smithies <justine@smithies.me.uk>2024-12-16 18:52:37 +0000
committerJustine Smithies <justine@smithies.me.uk>2024-12-16 18:52:37 +0000
commit957b3a05e758907c7b5b0355aece3e1259143571 (patch)
treed83fb52224e2da0c3fd4de58d273542e31092073 /.config/eww/scripts/brightnesscontrol.sh
parent70e01478b0f62bbf11ead24ad7b64ce1978c1ea1 (diff)
Renamed brightnesscontrol to brightnesscontrol.sh and converted from bash to sh.
Diffstat (limited to '.config/eww/scripts/brightnesscontrol.sh')
-rwxr-xr-x.config/eww/scripts/brightnesscontrol.sh39
1 files changed, 39 insertions, 0 deletions
diff --git a/.config/eww/scripts/brightnesscontrol.sh b/.config/eww/scripts/brightnesscontrol.sh
new file mode 100755
index 0000000..69ce422
--- /dev/null
+++ b/.config/eww/scripts/brightnesscontrol.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# 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
+
+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