DEV Community

Jacopo Valanzano
Jacopo Valanzano

Posted on

Linux Display Brightness

If you use the beloved X11, you might occasionally encounter difficulties adjusting the screen brightness. This is especially true if your system has a discrete GPU.

To overcome this issue, here are two simple Bash commands designed to gradually increase and decrease the screen brightness:

increaseBrightness(){
        xrandr --output eDP-1-1 --brightness $(bc <<< $(xrandr --verbose | grep -m 1 -i Brightness | cut -f2 -d ' ')+0.01 );
}

decreaseBrightness(){
        xrandr --output eDP-1-1 --brightness $(bc <<< $(xrandr --verbose | grep -m 1 -i Brightness | cut -f2 -d ' ')-0.01 );
}
Enter fullscreen mode Exit fullscreen mode

Use xrandr to find the Embedded DisplayPort (eDP) connection, if needed.

You can also create aliases to make your life easier:

# Increase Brightness
alias increaseBrightness="increaseBrightness"
# Decrease Brightness
alias decreaseBrightness="decreaseBrightness"
Enter fullscreen mode Exit fullscreen mode

Top comments (0)