diff options
author | Vikas Kushwaha <dev@vikas.rocks> | 2024-11-21 13:30:52 +0530 |
---|---|---|
committer | Vikas Kushwaha <dev@vikas.rocks> | 2024-11-21 13:30:52 +0530 |
commit | 5c916d69d457101326803eb076a746060e3618cf (patch) | |
tree | d6fce3256eede1c1bf78fb6a1be75b9cc4b84cee /.local/bin/desktop/brightness |
Moved from github
Diffstat (limited to '.local/bin/desktop/brightness')
-rwxr-xr-x | .local/bin/desktop/brightness | 32 |
1 files changed, 32 insertions, 0 deletions
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 <up|down>"; } + +[ "$#" -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 |