diff options
| author | JaKooLit <jimmielovejay@gmail.com> | 2023-10-22 15:55:57 +0900 |
|---|---|---|
| committer | JaKooLit <jimmielovejay@gmail.com> | 2023-10-22 15:55:57 +0900 |
| commit | c222e1bad2ba5e779c3af5b956906c82ead43271 (patch) | |
| tree | a5253e0861c200ff90354169e1f67ef42ebf0ef9 /config/hypr/scripts/BrightnessKbd.sh | |
| parent | bb0be21dba7980fc1c047eaba24eda1712bd7f31 (diff) | |
Initial upload
Diffstat (limited to 'config/hypr/scripts/BrightnessKbd.sh')
| -rwxr-xr-x | config/hypr/scripts/BrightnessKbd.sh | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/config/hypr/scripts/BrightnessKbd.sh b/config/hypr/scripts/BrightnessKbd.sh new file mode 100755 index 00000000..f48dc1c9 --- /dev/null +++ b/config/hypr/scripts/BrightnessKbd.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +iDIR="$HOME/.config/dunst/icons" + +# Get keyboard brightness +get_kbd_backlight() { + echo $(brightnessctl -d '*::kbd_backlight' -m | cut -d, -f4) +} + +# Get icons +get_icon() { + current=$(get_kbd_backlight | sed 's/%//') + if [ "$current" -le "20" ]; then + icon="$iDIR/brightness-20.png" + elif [ "$current" -le "40" ]; then + icon="$iDIR/brightness-40.png" + elif [ "$current" -le "60" ]; then + icon="$iDIR/brightness-60.png" + elif [ "$current" -le "80" ]; then + icon="$iDIR/brightness-80.png" + else + icon="$iDIR/brightness-100.png" + fi +} +# Notify +notify_user() { + notify-send -h string:x-dunst-stack-tag:brightness_notif -h int:value:$current -u low -i "$icon" "Keyboard Brightness : $current%" +} + +# Change brightness +change_kbd_backlight() { + brightnessctl -d *::kbd_backlight set "$1" && get_icon && notify_user +} + +# Execute accordingly +case "$1" in + "--get") + get_kbd_backlight + ;; + "--inc") + change_kbd_backlight "+30%" + ;; + "--dec") + change_kbd_backlight "30%-" + ;; + *) + get_kbd_backlight + ;; +esac |
