From 5c916d69d457101326803eb076a746060e3618cf Mon Sep 17 00:00:00 2001 From: Vikas Kushwaha Date: Thu, 21 Nov 2024 13:30:52 +0530 Subject: Moved from github --- .local/bin/desktop/brightness | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 .local/bin/desktop/brightness (limited to '.local/bin/desktop/brightness') diff --git a/.local/bin/desktop/brightness b/.local/bin/desktop/brightness new file mode 100755 index 0000000..11733f4 --- /dev/null +++ b/.local/bin/desktop/brightness @@ -0,0 +1,32 @@ +#!/bin/sh + +help() { echo "brightness - change screen brightness +USAGE: brightness "; } + +[ "$#" -lt 1 ] && help >&2 && exit 1 + +brightness="$(brightnessctl --machine-readable | cut -d, -f4 | tr -d %)" +step="$(( brightness / 10 + 1))" + +case "$1" in + up) brightnessctl --quiet set +${step}% ;; + down) brightnessctl --quiet set ${step}%- ;; + *) help >&2; exit 1 ;; +esac + +brightness="$(brightnessctl --machine-readable | cut -d, -f4)" + +if [ -n "$TMUX" ]; then + tmux display "Brightness: $brightness" + exit +fi + +notify() { [ -n "$DISPLAY" ] && notify-send -r 45234 "$1" "$2"; } +case "${brightness%\%}" in + [0-9]) notify "💡 Brightness: $brightness" ;; + [1-7][0-9]) notify "🔅 Brightness: $brightness" ;; + [89][0-9]) notify "🔆 Brightness: $brightness" ;; + 100) notify "🔆 MAX Brightness: $brightness" ;; + *) notify "brightness" "can't determine brightness" +esac +exit 0 -- cgit v1.2.3