Created
May 10, 2022 10:29
-
-
Save ilius/75590a429b5f334ef563c73050c6dccb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Discover monitor name with: xrandr | grep " connected" | |
# and set MONITOR | |
MONITOR="" | |
STEP="0.05" | |
MIN="0.1" | |
CurrBrightLine=$( xrandr --verbose --current | grep ^"$MONITOR" -A5 | tail -n1 ) | |
CurrBright="${CurrBrightLine##* }" | |
if [[ "$1" == "-" ]] ; then | |
Sign=- | |
elif [[ "$1" == "+" ]] ; then | |
Sign= | |
else | |
echo "invalid argument $1, must be + or -" >&2 | |
fi | |
NewBright=$(python -c "print(round(max($MIN, $CurrBright + $Sign$STEP), 3))") | |
xrandr --output "$MONITOR" --brightness "$NewBright" # Set new brightness | |
echo "$CurrBright --> $NewBright" | |
# printf "Monitor $MONITOR " | |
# echo $( xrandr --verbose --current | grep ^"$MONITOR" -A5 | tail -n1 ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment