diff options
Diffstat (limited to 'brightness.sh')
-rwxr-xr-x | brightness.sh | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/brightness.sh b/brightness.sh index a1c6648..cf2480f 100755 --- a/brightness.sh +++ b/brightness.sh @@ -9,20 +9,18 @@ maxbrightness_file="/sys/class/backlight/intel_backlight/max_brightness" # sudo ~/scripts/brightFirst.sh # fi -brightness=$(< "$brightness_file") -maxbrightness=$(< "$maxbrightness_file") -let target=$1+$brightness -sudo chmod 666 /sys/class/backlight/intel_backlight/brightness -if [ $target -gt $maxbrightness ] +brightness="$(cat "$brightness_file")" +maxbrightness="$(cat "$maxbrightness_file")" +target=$(($1+brightness)) +if [ $target -gt "$maxbrightness" ] then - sudo echo "$maxbrightness" >"$brightness_file" -elif [ 0 -gt $target ] + echo "$maxbrightness" | sudo tee "$brightness_file" +elif [ 0 -gt "$target" ] then - sudo echo "0" >"$brightness_file" + echo "0" | sudo tee "$brightness_file" else - sudo echo "$target" >"$brightness_file" + echo "$target" | sudo tee "$brightness_file" fi -sudo chmod 644 /sys/class/backlight/intel_backlight/brightness -dunstify -r $(dunstifyIDs.sh "brightness") -t 500 "$(~/scripts/i3blocks/i3brightness.sh)" +dunstify -r "$(dunstifyIDs.sh "brightness")" -t 500 "$(~/scripts/i3blocks/i3brightness.sh)" pkill -SIGRTMIN+11 i3blocks |