diff options
| author | Syndamia <kamen@syndamia.com> | 2023-07-17 11:45:40 +0300 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2023-07-17 11:45:40 +0300 |
| commit | 4edc468c240b9be5e42426d70f97869c39ccb956 (patch) | |
| tree | 45fee2a63db9729813001c1e71eb3919bbaf7e78 | |
| parent | 604e0a9c48d8b9d5ac738f5ae7ed80f94c7ecc61 (diff) | |
| download | dotfiles-4edc468c240b9be5e42426d70f97869c39ccb956.tar dotfiles-4edc468c240b9be5e42426d70f97869c39ccb956.tar.gz dotfiles-4edc468c240b9be5e42426d70f97869c39ccb956.zip | |
[brightness-control] Added a more intelligent and verbose way to change brightness
| -rwxr-xr-x | .a/brightness-control.sh | 28 | ||||
| -rw-r--r-- | .config/openbox/rc.xml | 4 |
2 files changed, 30 insertions, 2 deletions
diff --git a/.a/brightness-control.sh b/.a/brightness-control.sh new file mode 100755 index 0000000..3aa2139 --- /dev/null +++ b/.a/brightness-control.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +if [ -z "$@" ] || ([ "$1" != "+" ] && [ "$1" != "-" ]); then + echo "Expected + or - as argument!" + exit 1 +fi + +# Percentage change depending on brightness +info=$(brightnessctl -m i | cut -d , -f 4) +info=${info::-1} + +change=5 +if [ "$info" -ge 70 ]; then + change=10 +fi + +# Brightness change +if [ "$1" == "+" ]; then + brightnessctl -q set "+${change}%" +elif [ "$info" -gt 5 ]; then # don't allow brightness to decrease to 0% + brightnessctl -q set "${change}%-" +fi + +# Notification for brightness +info=$(brightnessctl -m i) +perbright=$(echo $info | cut -d , -f 4) +notify-send "$(echo $info | cut -d , -f 1) +Brightness: $perbright" -t 1000 -h int:value:$perbright -h string:x-canonical-private-synchronous:anything -h string:x-canonical-private-synchronous:anything diff --git a/.config/openbox/rc.xml b/.config/openbox/rc.xml index e4b23d1..cc74131 100644 --- a/.config/openbox/rc.xml +++ b/.config/openbox/rc.xml @@ -182,7 +182,7 @@ <enabled>false</enabled> <name>Brightness up</name> </startupnotify> - <command>brightnessctl set +5%</command> + <command>~/.a/brightness-control.sh +</command> </action> </keybind> <keybind key="XF86MonBrightnessDown"> @@ -191,7 +191,7 @@ <enabled>false</enabled> <name>Brightness down</name> </startupnotify> - <command>brightnessctl set 5%-</command> + <command>~/.a/brightness-control.sh -</command> </action> </keybind> <keybind key="W-d"> |
