Control screen brightness in i3

To change your screen brightness, you can use xrandr.

In order to do this, you can do:

xrandr -q | grep ' connected' | head -n 1 | cut -d ' ' -f1

That will return all the connected monitors (like LVDS-1 or DVI-D-0 for instance).

Now, to change the screen brightness do the command (replace the DVI-D-0 by the precedent command output):

xrandr --output DVI-D-0 --brightness 0.7

For instance, this command sets the brightness to 70%.

I hope it will help !


brightnessctl can be used to set the actual device brightness.


Copying from an old answer of mine to a question: XF86MonBrightnessUp/XF86MonBrightnessDown special keys not working


Edit: As noted below, you must have acpi installed on your machine for these to work :)

This is an old question, but an answer may help out others. I ran into an issue upon a fresh installation of i3wm on my laptop where, for whatever reason, my XF86MonBrightnessUp/Down keys weren't being registered (I checked with xev). What I ended up doing is creating acpi actions and events which corresponded to the keys being pressed.

The following are the actions/events I defined in /etc/acpi/actions and /etc/acpi/events, respectively:

Actions

/etc/acpi/actions/bl-down.sh

#!/bin/sh

bl_device=/sys/class/backlight/acpi_video0/brightness
echo $(($(cat $bl_device)-1)) | sudo tee $bl_device

/etc/acpi/actions/bl-up.sh

#!/bin/sh

bl_device=/sys/class/backlight/acpi_video0/brightness
echo $(($(cat $bl_device)+1)) | sudo tee $bl_device

Events

/etc/acpi/events/bl-down

event=video/brightnessdown BRTDN 00000087 00000000
action=/etc/acpi/actions/bl-down.sh

/etc/acpi/events/bl-up

event=video/brightnessup BRTUP 00000086 00000000
action=/etc/acpi/actions/bl-up.sh

You can verify your brightnessup/down acpi event codes by using acpi_listen in your terminal and then pressing the relevant key combination (e.g., for me, it's Fn + Down Arrow for brightness down).

Finally, don't forget to restart acpid with sudo /etc/init.d/acpid reload

Note: Your backlight device may be defined in a different location than /sys/class/backlight/acpi_video0 - that's just where mine happened to be. Do some poking around.

Tags:

Brightness

I3