Created
May 3, 2020 18:46
-
-
Save craigmbooth/b2dfa5944ab0dfdf082835347045fe68 to your computer and use it in GitHub Desktop.
Bash snippet that changes the brightness of a monitor
This file contains hidden or 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 | |
| # Usage: change_brightness <device_name> (+/-) | |
| # I use this in my i3 config to allow the brightness buttons to work on my Thinkpad | |
| set -e | |
| get_display_info() { | |
| local device=$1 | |
| local key=$2 | |
| echo $(xrandr --verbose | grep -m 1 -w "$device connected" -A8 | \ | |
| grep $key | cut -f2- -d: | tr -d " ") | |
| } | |
| device=$1 | |
| operator=$2 | |
| current_brightness=$(get_display_info $device Brightness) | |
| new_brightness=$(python -c "print(max([0.1, min([2.0, $current_brightness $operator 0.15])]))") | |
| xrandr --output $device --brightness $new_brightness |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment