Created
January 9, 2025 13:52
-
-
Save ottosch/ba101b32814c89eebc2626ac3fe00fd6 to your computer and use it in GitHub Desktop.
Change screen brightness for the terminal
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
#! /usr/bin/env bash | |
# Sets brightness to parameter level [0, max_brightness] | |
# Default: 10_000 | |
default=10000 | |
brightness=${1:-$default} | |
max="$(cat /sys/class/backlight/*/max_brightness)" | |
if test "$brightness" -eq "$brightness" 2>/dev/null; then # numeric value | |
if [ "$brightness" -gt "$max" ]; then | |
brightness="$max" | |
elif [ "$brightness" -lt 0 ]; then | |
brightness=0 | |
fi | |
else | |
brightness="$default" | |
fi | |
echo "Setting brightness to $brightness" | |
echo "$brightness" | sudo tee /sys/class/backlight/*/brightness >/dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment