Add backlight script
This commit is contained in:
parent
8b82ba2445
commit
77c58e5f98
4 changed files with 48 additions and 3 deletions
.local/bin
43
.local/bin/backlight
Executable file
43
.local/bin/backlight
Executable file
|
@ -0,0 +1,43 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
path="/sys/class/backlight/intel_backlight"
|
||||
|
||||
current_abs=$(cat "$path/actual_brightness")
|
||||
max_abs=$(cat "$path/max_brightness")
|
||||
|
||||
percent=$(( max_abs / 100 ))
|
||||
current=$(( current_abs / percent ))
|
||||
new="$current"
|
||||
|
||||
change=$2
|
||||
|
||||
if [ "$1" = "-get" ]
|
||||
then
|
||||
echo "$current"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "-inc" ]
|
||||
then
|
||||
new=$(( current + change ))
|
||||
fi
|
||||
if [ "$1" = "-dec" ]
|
||||
then
|
||||
new=$(( current - change ))
|
||||
fi
|
||||
if [ "$1" = "-set" ]
|
||||
then
|
||||
new=$2
|
||||
fi
|
||||
|
||||
if [ "$new" -lt 10 ]
|
||||
then
|
||||
new=10
|
||||
fi
|
||||
if [ "$new" -gt 100 ]
|
||||
then
|
||||
new=100
|
||||
fi
|
||||
|
||||
echo "$(( new * percent ))" | tee "$path/brightness"
|
Loading…
Add table
Add a link
Reference in a new issue