Skip to content

Instantly share code, notes, and snippets.

@piersy
Created September 14, 2018 10:18
Show Gist options
  • Save piersy/0a4b690560e6f2dfa86f27e04d36683a to your computer and use it in GitHub Desktop.
Save piersy/0a4b690560e6f2dfa86f27e04d36683a to your computer and use it in GitHub Desktop.
Easily set brightness of connected monitors via xrandr
#!/bin/bash
# Match 0.x-1
REGEX='^0.+([0-9]+)+$|1'
SCRIPT_NAME=`basename "$0"`
if ! [[ $1 =~ $REGEX ]] ; then
echo "Usage: ${0##*/} <brightness_value_0.x_to_1>" >&2; exit 1
fi
OUTPUTS=`xrandr | grep connected | grep "mm$" | awk '{print $1}'`
for x in $OUTPUTS; do
xrandr --output $x --brightness $1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment