diff options
Diffstat (limited to '.local/bin/bl')
-rwxr-xr-x | .local/bin/bl | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/.local/bin/bl b/.local/bin/bl index da1980e..ee71504 100755 --- a/.local/bin/bl +++ b/.local/bin/bl @@ -29,13 +29,25 @@ main() case "$1" in inc) - xbacklight -inc ${2:-5} + brightnessctl set +${2:-5}% notify="Brightness increased to $(brightness_level)%" ;; dec) - xbacklight -dec ${2:-5} + if [ $(brightness_level) -lt $(( ${2:-5} + 1 )) ] + then + brightnessctl set 1 + else + brightnessctl set ${2:-5}%- + fi + notify="Brightness lowered to $(brightness_level)%" ;; + set) + [ -z "$2" ] && usage && exit 1 + + brightnessctl set $2% + notify="Brightness set to $(brightness_level)%" + ;; esac notify-send -n 57492 -s -t 2 -i "$(brightness_icon)" "Backlight" "$notify" @@ -43,7 +55,7 @@ main() brightness_level() { - xbacklight -get + awk "BEGIN { printf(\"%d\", ($(brightnessctl get) / $(brightnessctl max)) * 100) }" } brightness_icon() @@ -61,8 +73,16 @@ usage() cat <<EOF Usage: ${0##*/} -h + ${0##*/} inc [level] + ${0##*/} dec [level] + ${0##*/} set <level> + +Alter the backlight intensity. -Nondescript +Subcommands: + inc Increase the volume by level, defaults to 5. + dec Decrease the volume by level, defaults to 5. + set Set the volume to level. Options: -h Show this help text and exit. |