#! /bin/bash
if [ ! -w /sys/class/backlight/intel_backlight/brightness ];then
echo "password" | sudo -S chmod 777 /sys/class/backlight/intel_backlight/brightness
fi
read bright < /sys/class/backlight/intel_backlight/brightness
v=$((88 + $bright))
if [ $v -gt 976 ]; then
v=976
# 937为我的最大亮度,即max_brightness文件里面的值
fi
if [ ! -w /sys/class/backlight/intel_backlight/brightness ];then
echo "password" | sudo -S chmod 777 /sys/class/backlight/intel_backlight/brightness
fi
read bright < /sys/class/backlight/intel_backlight/brightness
v=$((88 + $bright))
if [ $v -gt 976 ]; then
v=976
# 937为我的最大亮度,即max_brightness文件里面的值
fi
echo $v > /sys/class/backlight/intel_backlight/brightness
sudo -S 接受管道输入即 echo 'pass' | sudo -S 即sudo下的免密