aboutsummaryrefslogtreecommitdiff
path: root/.config/waybar/scripts/brightnesscontrol.sh
diff options
context:
space:
mode:
authorJustine Smithies <justine@smithies.me.uk>2025-06-15 12:38:40 +0100
committerJustine Smithies <justine@smithies.me.uk>2025-06-15 12:38:40 +0100
commitb90ad8355b4b71ad328aba0943a62a123fb5b88d (patch)
tree58d8bba26b6a2a866af4abe138961adb2c32e9d3 /.config/waybar/scripts/brightnesscontrol.sh
parentd029adec94282882510be0d4398709a818b880ad (diff)
Initial commit for MaomaoWM - Still a WIP
Diffstat (limited to '.config/waybar/scripts/brightnesscontrol.sh')
-rwxr-xr-x.config/waybar/scripts/brightnesscontrol.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/.config/waybar/scripts/brightnesscontrol.sh b/.config/waybar/scripts/brightnesscontrol.sh
new file mode 100755
index 0000000..a59e410
--- /dev/null
+++ b/.config/waybar/scripts/brightnesscontrol.sh
@@ -0,0 +1,40 @@
+#!/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
+ ;;
+ *)
+ text=$(backlight -q)
+ icon=""
+ # printf "%s" "$icon $brightness" "%"
+ echo "{\"text\":\""$text"\", \"tooltip\":\""$tooltip"\"}"
+ ;;
+esac