aboutsummaryrefslogtreecommitdiff
path: root/.config/qtile/statusbar/brightnesscontrol
diff options
context:
space:
mode:
authorJustine Smithies <justine@smithies.me.uk>2023-08-22 19:46:15 +0100
committerJustine Smithies <justine@smithies.me.uk>2023-08-22 19:46:15 +0100
commit6aaea9cf4b283d41016e60735f52c8feb3cd0c9e (patch)
treeffc170bb7f267247b60908ac9125fcc02175afd9 /.config/qtile/statusbar/brightnesscontrol
parent86c0c3694c93025dfec23f27266905c12f446a4e (diff)
Initial commit
Diffstat (limited to '.config/qtile/statusbar/brightnesscontrol')
-rwxr-xr-x.config/qtile/statusbar/brightnesscontrol44
1 files changed, 44 insertions, 0 deletions
diff --git a/.config/qtile/statusbar/brightnesscontrol b/.config/qtile/statusbar/brightnesscontrol
new file mode 100755
index 0000000..304c187
--- /dev/null
+++ b/.config/qtile/statusbar/brightnesscontrol
@@ -0,0 +1,44 @@
+#!/bin/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/Papirus-Dark/16x16/actions/brightnesssettings.svg
+ brightness=$(light -G)
+ brightness=$(echo "$brightness" | awk '{print ($0-int($0)<0.499)?int($0):int($0)+1}')
+ # 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')
+ #brightness=$((brightness *100 / 255 ))
+ #echo $bar
+ #echo $test
+ # Send the notification
+ notify-send -i "$icon" -r 5555 -u normal "$bar $brightness"
+}
+
+case $1 in
+ up)
+ # increase the backlight by 5%
+ light -A 5
+ send_notification
+ canberra-gtk-play -i audio-volume-change
+ ;;
+ down)
+ # decrease the backlight by 5%
+ light -U 5
+ send_notification
+ canberra-gtk-play -i audio-volume-change
+ ;;
+ *)
+ brightness=$(light -G)
+ brightness=$(echo "$brightness" | awk '{print ($0-int($0)<0.499)?int($0):int($0)+1}')
+ icon="󰃞"
+ printf "%s" "$icon $brightness" "%"
+ ;;
+esac