Skip to content

Instantly share code, notes, and snippets.

@HarshitRuwali
Last active July 23, 2021 08:02
Show Gist options
  • Save HarshitRuwali/e20b553095cc6e788f41c8d874cdf2e3 to your computer and use it in GitHub Desktop.
Save HarshitRuwali/e20b553095cc6e788f41c8d874cdf2e3 to your computer and use it in GitHub Desktop.
Wrapper to change brightness of laptop's display in linux using xrandr.
#!/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