Last active
July 23, 2021 08:02
-
-
Save HarshitRuwali/e20b553095cc6e788f41c8d874cdf2e3 to your computer and use it in GitHub Desktop.
Wrapper to change brightness of laptop's display in linux using xrandr.
This file contains 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 | |
if [ "$1" == "-h" ] || [ -z "$1" ] | |
then | |
echo " Set the brightness of the primary display i.e. laptop's one. | |
Usage: $(basename "$0") [-h] [-b brightness_value] | |
where: | |
-h show this help text | |
-b set the brightness in range [0,1]" | |
exit 0 | |
fi | |
while getopts b: flag | |
do | |
case "${flag}" in | |
b) brightness_val=${OPTARG};; | |
esac | |
done | |
# detect the primary display i.e. laptop's one and change the brightness | |
xrandr --output $(xrandr -q | grep ' connected' | head -n 1 | cut -d ' ' -f1) --brightness $brightness_val | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment