Skip to content

Instantly share code, notes, and snippets.

@bweigel
Last active January 4, 2018 19:15
Show Gist options
  • Save bweigel/21de4a43ddee09c1a804c3df474344f3 to your computer and use it in GitHub Desktop.
Save bweigel/21de4a43ddee09c1a804c3df474344f3 to your computer and use it in GitHub Desktop.
[LINUX] Change display brightness of all connected screens
#!/bin/bash
BRIGHTNESS=$1
if [[ $(echo "${BRIGHTNESS} >= 0.2 && ${BRIGHTNESS} <= 1" | bc) = 1 ]]; then
for disp in $(xrandr | awk '{print $1,$2}' | grep -P '(?<!dis)connected' | awk '{print $1}'); do
echo "Setting brightness in display ${disp} to ${BRIGHTNESS}..."
xrandr --output $disp --brightness ${BRIGHTNESS}
done
else
echo "A brightness of ${BRIGHTNESS} may be not such a good idea..."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment