Created
November 14, 2016 19:40
-
-
Save ldante86/e532ecc4cba6342d05b46268aa7b0360 to your computer and use it in GitHub Desktop.
Dim the screen with xbacklight using 1, 2, 3 buttons.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash - | |
# Dim the screen with xbacklight using 1, 2, 3 buttons. | |
dim() | |
{ | |
local prog=/usr/bin/xbacklight | |
local step=20 state | |
which $prog >/dev/null | |
case $? in | |
1) echo $prog is not installed | |
return 1 | |
esac | |
while true | |
do | |
state=$($prog -get) | |
echo -n "${state%%.*}%% " | |
read -sn1 | |
case $REPLY in | |
1|[Ww]) $prog -inc $step ;; | |
2|[Ss]) $prog -dec $step ;; | |
3|[Xx]) echo; break ;; | |
*) continue ;; | |
esac | |
state=$($prog -get) | |
if ((${state%%.*}==100)) || ((${state%%.*}==0)); then | |
echo ${state%%.*}%% | |
return 1 | |
fi | |
done | |
} | |
dim |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment