I'm trying to write a script that get the actual brightness and decrease the string number by 0.1. I've tried numerous syntax but since I'm very new to bash this doesn't work.
#!/bin/sh
actualBrightness=$(xrandr --verbose | grep -i brightness | cut -f2 -d ' ')
echo ${actualBrightness} # 0.5 for ex
if [[ $actualBrightness < 1 ]]
then
newBrightness=$(($actualBrightness-0.1))
echo $newBrightness # must be 0.4
fi
#!/bin/shand[[ ]], but[[ ]]is a bash feature.[[ $actualBrightness < 1 ]]is doing a string comparison. Even for integers, you want to use actual integer math -- as a string, for instance,20is greater than100, since comparison is character-by-character left-to-right.