Shortcut Script to Adjust Screen Brightness in Ubuntu Command Line

You can’t get your screen brightness keys to work on your Sony Vaio (or other computer) with Ubuntu. You may have tried the “Brightness Controller” package only to find that it does not work on your machine. You may be frustrated that the only way for you to adjust your screen brightness is on the command line using the “xrandr” command. For example, to set the brightness to 50%:

xrandr --output LVDS1 --brightness 0.50 

Given that, you will find the following script at least a little bit easier. This script will let you adjust your screen brightness by typing just “bright” and a number between 1 and 9 into terminal.

It’s not as easy as using the brightness keys on your keyboard, but it’s easier than remembering the “xrandr” command from above. The entire process will be:

  1. Quicly open a terminal with Ctrl + Alt + T
  2. Enter: bright 5

This script is specifically written to work with Sony Vaio laptops. It should also work with any machine running Ubuntu, Peppermint, Xubuntu, or Lubuntu. Test it, and if it doesn’t work for you, you can simply delete it.

Create the Shortcut Script

Create a new file:

sudo gedit /usr/sbin/bright

You can replace “gedit” above with your default text editor, for example, “leafpad”.

In the file, paste this:

syntax="\\n \\t SYNTAX:  bright # \\n \\t Where # is any whole number from 1 to 9.\\n";
if [ 1$1 -gt 10 ];
if [ 1$1 -lt 20 ];
xrandr --output LVDS1 --brightness 0.$10;
echo -e $syntax;
echo -e $syntax;

Save and exit the file.

Give it proper permissions:

chmod a+x /usr/sbin/bright


To adjust the screen brightness, issue the following command:

sudo bright 5

You can replace the 5 with any number between 1 and 9. Using 1 will make the screen dimmest, while 9 will make it brightest.

See more: , , ,

We've One Response

  1. November 7th, 2021 at 9:47 am

    How do you manage to do something like:

    “xrandr –output DisplayPort-1 –brightness 1” and not fk up the night color control for that monitor in Kubuntu? It automatically acts like it kills the tint and overrides the Night color control.


Questions and Comments are Welcome

Your email address will not be published. All comments will be moderated.

Please wrap code in "code" bracket tags like this: