mirror of
https://github.com/Keyitdev/dotfiles.git
synced 2026-09-24 01:52:09 +00:00
38 lines
1.2 KiB
Bash
Executable File
38 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# default
|
|
step=+5
|
|
|
|
video_card=$(ls -1 /sys/class/backlight/)
|
|
|
|
while getopts s: flag
|
|
do
|
|
case "${flag}" in
|
|
s) step=${OPTARG};;
|
|
*) echo "Usage: -s <-value/+value>";;
|
|
esac
|
|
done
|
|
|
|
if [ -n "$video_card" ] && [ -d "/sys/class/backlight/$video_card" ]; then
|
|
step=$(echo "$step" | sed 's/+//g')
|
|
cur_brightness=$(cat /sys/class/backlight/"$video_card"/brightness)
|
|
max_brightness=$(cat /sys/class/backlight/"$video_card"/max_brightness)
|
|
|
|
step_c=$(( (step*max_brightness)/100 ))
|
|
# step_c=$(echo "scale=2; $step*($max_brightness/100)" | bc -l | sed 's/\..*$//')
|
|
new_brightness=$((cur_brightness + step_c))
|
|
|
|
if [ "$new_brightness" -le "0" ]; then
|
|
echo "0" > /sys/class/backlight/"$video_card"/brightness
|
|
elif [ "$new_brightness" -ge "$max_brightness" ] ; then
|
|
echo "$max_brightness" > /sys/class/backlight/"$video_card"/brightness
|
|
else
|
|
echo "$new_brightness" > /sys/class/backlight/"$video_card"/brightness
|
|
fi
|
|
|
|
else
|
|
sign=$(printf "%s" "$step" | cut -c1)
|
|
value=$(printf "%s" "$step" | sed 's/^[-+]//')
|
|
|
|
ddcutil --disable-dynamic-sleep --noverify --skip-ddc-checks --sleep-multiplier 0.1 --bus 12 setvcp 10 "$sign" "$value"
|
|
fi |