Skip to content

Instantly share code, notes, and snippets.

@fsmithred
Last active April 5, 2016 15:30
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 fsmithred/5a6c07872ab49f3079f3352c9b3ef0c6 to your computer and use it in GitHub Desktop.
Save fsmithred/5a6c07872ab49f3079f3352c9b3ef0c6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# set_bright4
set -x
# Set these names according to what xrandr tells you.
# For a single monitor, comment out the second xrandr line at the bottom.
monitor_1="DVI-I-1"
monitor_2="VGA-1"
get_current_values () {
current_bright=$(xrandr --verbose | grep -m1 Brightness | cut -d" " -f2)
current_gamma=$(xrandr --verbose |grep -m1 Gamma | cut -d":" -f3)
gamma1="$current_gamma"
}
select_values () {
values=$(yad --form --field=Brightness:NUM --field=Gamma:NUM \
"${current_bright}\!0.20..1.20\!0.1\!2" \
"${current_gamma}\!0.5..1.5\!0.1\!1")
exit_code="$?"
if [[ $exit_code -eq 1 ]] ; then
exit 0
fi
value1=$(echo "$values" | awk -F"|" '{ print $1 }')
value2=$(echo "$values" | awk -F"|" '{ print $2 }')
new_bright="${value1:0:4}"
new_gamma="${value2:0:3}"
}
get_current_values
select_values
# Less bright setting for second monitor.
new_bright2="0$(echo $new_bright - 0.10 | bc)"
# For single monitor, comment out second xrandr command.
# For two monitors with same brightness, edit second xrandr command;
# change "$new_bright2" to "$new_bright"
xrandr --output "$monitor_1" --brightness "$new_bright" --gamma "${new_gamma}:${new_gamma}:${new_gamma}"
xrandr --output "$monitor_2" --brightness "$new_bright2" --gamma "${new_gamma}:${new_gamma}:${new_gamma}"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment