diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2024-06-03 19:56:39 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2024-06-03 19:56:39 +0800 |
| commit | ca968c4e5040f1ff4b5b5e12d9312360d807dcc1 (patch) | |
| tree | 9900920e8f566794560c1519678e344351d2803b /dot-config/bspwm/scripts/bspbrightness | |
| parent | 5f3deaff0bf006a1a353e57b82ad48c0e8f143bc (diff) | |
added submodules, change . -> dot (see man stow --dotfiles)
Diffstat (limited to 'dot-config/bspwm/scripts/bspbrightness')
| -rwxr-xr-x | dot-config/bspwm/scripts/bspbrightness | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/dot-config/bspwm/scripts/bspbrightness b/dot-config/bspwm/scripts/bspbrightness new file mode 100755 index 00000000..cdf67047 --- /dev/null +++ b/dot-config/bspwm/scripts/bspbrightness @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +## Script to manage brightness on Archcraft. + +# Icons +iDIR='/usr/share/archcraft/icons/dunst' + +# Graphics card +CARD=`ls /sys/class/backlight | head -n 1` + +# Get brightness +get_backlight() { + if [[ "$CARD" == *"intel_"* ]]; then + BNESS=`xbacklight -get` + LIGHT=${BNESS%.*} + else + LIGHT=$(printf "%.0f\n" `light -G`) + fi + echo "${LIGHT}%" +} + +# Get icons +get_icon() { + backlight="$(get_backlight)" + current="${backlight%%%}" + if [[ ("$current" -ge "0") && ("$current" -le "20") ]]; then + icon="$iDIR"/brightness-20.png + elif [[ ("$current" -ge "20") && ("$current" -le "40") ]]; then + icon="$iDIR"/brightness-40.png + elif [[ ("$current" -ge "40") && ("$current" -le "60") ]]; then + icon="$iDIR"/brightness-60.png + elif [[ ("$current" -ge "60") && ("$current" -le "80") ]]; then + icon="$iDIR"/brightness-80.png + elif [[ ("$current" -ge "80") && ("$current" -le "100") ]]; then + icon="$iDIR"/brightness-100.png + fi +} + +# Notify +notify_bl() { + get_icon && dunstify -u low -h string:x-dunst-stack-tag:obbacklight -i "$icon" "Brightness : $(get_backlight)" +} + +# Increase brightness +inc_backlight() { + if [[ "$CARD" == *"intel_"* ]]; then + xbacklight -inc 10 && notify_bl + else + light -A 5 && notify_bl + fi +} + +# Decrease brightness +dec_backlight() { + if [[ "$CARD" == *"intel_"* ]]; then + xbacklight -dec 10 && notify_bl + else + light -U 5 && notify_bl + fi +} + +# Execute accordingly +if [[ "$1" == "--get" ]]; then + get_backlight +elif [[ "$1" == "--inc" ]]; then + inc_backlight +elif [[ "$1" == "--dec" ]]; then + dec_backlight +else + get_backlight +fi |
