Category Archives: i3m

i3wm brightness control on T480s

I got a new laptop – Thinkpad t480s – it is a great machine!
But since I like to use i3wm for my work, there was a bit of a problem with the way I control the brightness on my old machine. I had two scripts which were triggering when I press the function keys which were detected as XF86MonBrightnessDown and XF86MonBrightnessUp

The problem is that this newer machine was not detecting these keys with xev and when I was using the function keys for the screen brightness acpi events were triggered, so I needed to find how to catch the key presses.

So bellow is what I used in order to control my brightness.
First of all you need to find out what keys acpi detects, you can do that with acpi_list.
In my case the output of it was the keys video/brightnessup BRTUP 00000086 00000000
and video/brightnessdown BRTDN 00000087 00000000

So the next step is to add new acpi event. This is very straightforward, for ubuntu you just go to the /etc/acpi/events/ folder and create two files there – one for increasing the brightness and one for decreasing it. What you put in these files is simply what command or script to be executed when that key is pressed. I will give example with just the brightness increase scripts, as the brightness decrease are basically the same, just the key and script is different, so you should not have any problems adding the others.

So my /etc/acpi/events/brightness_up looks like this

# /etc/acpi/events/brightness_up
# This is called when the user presses the brightness up button and calls
# /home/ivan/.config/i3/ which will increase the screen brightness.
# Author: Ivan Denkov

event=video/brightnessup BRTUP 00000086 00000000

This trigger the script located in /etc/acpi/ you need to make that script executable, and this are the contents to go there. Here is the script:

CAT="$(which cat)"
current_brightness=`$CAT /sys/class/backlight/intel_backlight/brightness`
echo $new_brightness > /sys/class/backlight/intel_backlight/brightness

You just need to replicate the event and the script for lowering the brightness and you should be good to go.
If for some reason the above does not work, make sure that:
– You have made the bash scripts executable.
– Make sure the bash scripts by itself can change the brightness(It is actually working)
– Double check acpi_listen to make sure you have put the correct keys in the events.

I assume it will be practically the same procedure on the Thinkpad T480.

Remap print key to Super(windows) in i3wm

My laptop keyboard is little annoying – it have a Print Screen(PrtSc) button between my right control and alt keys – usually around that area you will find the windows(super) key, so I wanted to remap it, when i am using i3wm.

So first of all you need to make sure what is your key “called”, you can to that with the xev program.

Then you need to get your modifier map with: xmodmap -pm
In my case my output was this:

xmodmap:  up to 4 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  Alt_R (0x6c),  Meta_L (0xcd)
mod2        Num_Lock (0x4d)
mod4        Super_L (0x85),  Super_R (0x86),  Super_L (0xce),  Hyper_L (0xcf)
mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)

I use mod4 for my i3 config, so I needed to add the Print key to the mod4 modifier with this command:

xmodmap -e "add mod4 = Print"

After that we see that Print is added to the mod4:

mod4        Print (0x6b),  Super_L (0x85),  Super_R (0x86),  Super_L (0xce),  Hyper_L (0xcf),  Print (0xda)

And you will probably want to add this command to your i3 config so it get excuted on each boot:

exec --no-startup-id /usr/bin/xmodmap -e "add mod4 = Print"