Skip to content

Instantly share code, notes, and snippets.

@ilius
Created May 10, 2022 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilius/75590a429b5f334ef563c73050c6dccb to your computer and use it in GitHub Desktop.
Save ilius/75590a429b5f334ef563c73050c6dccb to your computer and use it in GitHub Desktop.
#!/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