quick update: change display brightness

Published on 2 Jan 2019

I needed a way to feasibly change display brightness because physically changing it on the monitor itself is not that practical. Task like this should be able to be controlled from the OS.

Thankfully, it is possible to control the brightness from the OS (my current OS is Ubuntu 18.04 LTS). I found a short blog post on OMG Ubuntu on Brightness Controller, and I was happy with this solution… temporarily. I was thankful to know that this package worked, but I was looking something more geek-y, like, using the terminal. Also, I like simple solutions that do not require me to install additional packages or adding new PPAs.

brightness controller

And I found the way to do that. Turned out, it was really simple. This method, however, can only work with Xorg display server, not with wayland display server. The tool here is called the xrandr (X-render?).

First, I queried the monitor information with xrandr --listmonitors command:

aixnr@natalya ~> xrandr --listmonitors
Monitors: 1
 0: +*HDMI-0 1920/527x1080/296+0+0  HDMI-0

It listed HDMI-0 as the sole output here. Cool. It detected my output. Then, I used the --brightness output to change the brightness. xrandr accepts fractions (0.0 - 1.0) as the value for the brightness, with 1 being 100% of the default brightness level. So, to decrease the brightness by half, I did this:

xrandr --output HDMI-0 --brightness 0.5

And it worked! Cool cool cool. But, I did not want to type a long command just to change the brightness. Then, I decided to use the alias dim for this operation. Since I am using fish shell, the function looks like this:

function dim
  xrandr --output HDMI-0 --brightness $argv[1]
end

And now, with a simple dim 0.5, the brightness level goes down by half.