From 1cace80e4832a5d250ef4b7ccd687996563fb01b Mon Sep 17 00:00:00 2001 From: venomade Date: Thu, 27 Feb 2025 17:06:42 +0000 Subject: Add old dotfiles --- swaywm/local/bin/brightness | 52 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 swaywm/local/bin/brightness (limited to 'swaywm/local/bin/brightness') diff --git a/swaywm/local/bin/brightness b/swaywm/local/bin/brightness new file mode 100755 index 0000000..2c8ebb4 --- /dev/null +++ b/swaywm/local/bin/brightness @@ -0,0 +1,52 @@ +#!/bin/bash + +function get_brightness { + cntb=$(brightnessctl g) + maxb=$(brightnessctl m) + + echo $(( ($cntb * 100) / $maxb )) +} + +# Function to get the icon based on the brightness level +function get_brightness_icon { + brightness_level=$1 + if [ $brightness_level -le 33 ]; then + echo "󰃞" + elif [ $brightness_level -le 66 ]; then + echo "󰃟" + else + echo "󰃠" + fi +} + +# Function to set the contents of "/tmp/brightness_status" to the current brightness level +function set_tmp_brightness_status { + brightness_level=$(get_brightness) + icon=$(get_brightness_icon $brightness_level) + echo "$icon $brightness_level%" > /tmp/brightness_status +} + +function send_notification { + brightness_level=$(get_brightness) + icon=$(get_brightness_icon $brightness_level) + # Make the bar with the special character ─ (it's not dash -) + # https://en.wikipedia.org/wiki/Box-drawing_character + bar=$(seq -s "─" $(($brightness_level / 5)) | sed 's/[0-9]//g') + # Send the notification + dunstify -i display-brightness-symbolic -t 2500 -r 2593 -u normal " $bar" +} + +case $1 in + up) + # Set the brightness level up (+ 5%) + brightnessctl s 5%+ + send_notification + set_tmp_brightness_status + ;; + down) + # Set the brightness level down (- 5%) + brightnessctl s 5%- + send_notification + set_tmp_brightness_status + ;; +esac -- cgit 1.4.1-2-gfad0