diff --git a/.config/i3/config.d/keymap.conf b/.config/i3/config.d/keymap.conf index 86ac3b0..dd38697 100644 --- a/.config/i3/config.d/keymap.conf +++ b/.config/i3/config.d/keymap.conf @@ -43,8 +43,8 @@ bindsym XF86AudioMute exec --no-startup-id x-volume mute bindsym XF86AudioMicMute exec --no-startup-id x-mic-mute # brightness control -bindsym XF86MonBrightnessUp exec --no-startup-id x-brightness-up -bindsym XF86MonBrightnessDown exec --no-startup-id x-brightness-down +bindsym XF86MonBrightnessUp exec --no-startup-id x-brightness up +bindsym XF86MonBrightnessDown exec --no-startup-id x-brightness down # media controls bindsym XF86AudioPlay exec playerctl play-pause diff --git a/.local/bin/x-brightness b/.local/bin/x-brightness new file mode 100755 index 0000000..ad6bb99 --- /dev/null +++ b/.local/bin/x-brightness @@ -0,0 +1,26 @@ +#!/usr/bin/env sh + +[ -z "$AMOUNT" ] && AMOUNT=5 + +notify() { + notify-send "$@" -h string:x-dunst-stack-tag:'brightnessctl' -a 'brightnessctl' +} + +max=$(brightnessctl max) +br=$(brightnessctl get) +brp=$((100 * br / max)) + +case "$1" in +up) brp=$((brp + AMOUNT)) ;; +down) brp=$((brp - AMOUNT)) ;; +*) + echo 'E: could not decide what brightness action to perform!' >&2 + notify 'could not decide what audio action to perform!' -u critical -t 5000 + exit 1 + ;; +esac +brp=$((brp - (brp % AMOUNT))) + +brightnessctl set $brp% +ico=display-brightness-symbolic +notify -u low -i "$ico" -h "int:value:$brp" "brightness: $brp%" diff --git a/.local/bin/x-brightness-down b/.local/bin/x-brightness-down deleted file mode 100755 index 45e6059..0000000 --- a/.local/bin/x-brightness-down +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/sh -br=$(brightnessctl set 5%- | - grep '%' | awk '{print $4}' | sed 's/[^0-9]//g') -notify-send -u low -i display-brightness-symbolic -h int:value:"$br" -h string:x-dunst-stack-tag:'brightnessctl' -a 'brightnessctl' "brightness: $br%" diff --git a/.local/bin/x-brightness-up b/.local/bin/x-brightness-up deleted file mode 100755 index 671c57b..0000000 --- a/.local/bin/x-brightness-up +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/sh -br=$(brightnessctl set 5%+ | - grep '%' | awk '{print $4}' | sed 's/[^0-9]//g') -notify-send -i display-brightness-symbolic -u low -h int:value:"$br" -h string:x-dunst-stack-tag:'brightnessctl' -a 'brightnessctl' "brightness: $br%"