3

My laptop's keyboard is half functional (literally, like half of the keys don't work), so I'm forced to use an external keyboard. However, since it doesn't have an Fn key (obviously), I want to create a custom keyboard shortcut to change the brightness up and down.

So, what command should I execute to change the brightness up or down? I want to create a custom keyboard shortcut for these commands.

Edit: I should point out that I took a look at the default keyboard shortcuts and found nothing to help me out.

1

The simple way to adjust brightness from terminal is using xrandr.

xrandr is used to set the size, orientation and/or reflection of the outputs for a screen. It can also set the screen size.

For more information about xrandr open terminal and run man xrandr.

First you need to find your display name,for that run the command in terminal:

xrandr -q | grep " connected"

For Example:

ravan@ravan:~$ xrandr -q | grep " connected"
VGA1 connected primary 1366x768+0+0 (normal left inverted right x axis y axis) 410mm x 230mm

Here,In my system VGA1 is display name. Replace VGA1 with your system display.

Now run:

 xrandr --output VGA1 --brightness 0.7

Here range from 0.0 to 1.0 .


Option 2:

To adjust screen brightness you can use xbacklight

Open terminal and run:

sudo apt-get install xbacklight

Usage:

usage: xbacklight [options]
where options are:
       -display <display> or -d <display>
       -help
       -set <percentage> or = <percentage>
       -inc <percentage> or + <percentage>
       -dec <percentage> or - <percentage>
       -get
       -time <fade time in milliseconds>
       -steps <number of steps in fade>

For example: xbacklight -inc 20 will increase by 20 percent.

  • 1
    I have dealt with this problem again, and while both xdotool and xbacklight changed nothing, xrandr did the trick. Thanks for the tip! – r3bl Mar 26 '16 at 12:39
1

You can use xdotool

sudo apt-get install xdotool

then control the brightness by executing

xdotool key XF86MonBrightnessDown

for decreasing and

xdotool key XF86MonBrightnessUp

for increasing. There are alternate options to change screen brightness but mostly they need root privileges and if you are trying to have key bindings, entering your password each time on an intermediate pop-up screen can be a bummer. You create custom keyboard shortcuts for these in systems setting (System Settings -> Keyboard -> Shortcuts -> Custom)

enter image description here

by pressing the + button at the bottom and inserting your command and its corresponding keyboard shortcut. You should log out and log back in for the effect to take place.

  • 1
    Well this is weird. Those commands work from the terminal, but I can't seem to map them to a keyboard shortcut. I tried three or four different key combinations and I logged out every time. Does this work for you? – r3bl Aug 16 '15 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.