Choose any key as the modifier in i3wm in 6 steps
Overview
Guide to choose any key of your keyboard as the modifier in the i31 (improved tiling window manager).
Motivation
The modifier key is essential in the i3 window manager as it is the main way to interact with it.
For an old mechanical keyboard which has not Windows (Mod4) key to use as modifier the default choice is to use the Alt (Mod1) key, but it limits the usage in many ways as it collides with many other programs’ keybindings.
1. Key alternatives
By default there is a list of possible keys which you can choose from
without much work, to get this list we use the command xmodmap
,
which is an “utility for modifying keymaps and pointer button mappings
in X” that shows the standards modifiers understood by i3.
$ xmodmap
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), Meta_L (0xcd)
mod2 Num_Lock (0x4d)
mod3
mod4 Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
mod5 ISO_Level3_Shift (0x5c), Mode_switch (0xcb)
2. Choose key
We will choose a new key that is not present as a candidate by the standard modifiers, in this case the PrtScn (the Print Screen key).
For this we need to get the key identifier, using xev
command (print contents of X events
).
Run xev and then press the desired key, ie.: PrtScn
, so
xev
will print that key information.
$ xev
KeyRelease event, serial 34, synthetic NO, window 0x2200001,
root 0x9f, subw 0x0, time 16682622, (-173,425), root:(1111,445),
state 0x0, keycode 107 (keysym 0xff61, Print), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
Now we know its keycode is 107 which will be used next.
3. Set new key as mod
We will set the mod3
modifier as the i3 modifier. For this we
create a file ~/.Xmodmap
:
! Print: set as modifier (mod3)
! set mod3 to Print key, so I can use it as i3 modifier
keycode 107 = Print
clear mod3
add mod3 = Print
4. Set new mod key
Load new configuration with xmodmap ~/.Xmodmap using “xmodmap - utility for modifying keymaps and pointer button mappings in X”.
$ xmodmap ~/.Xmodmap
5. Use mod in i3
In .config/i3/config
we use the set
command:
#set $mod Mod1
set $mod Mod3
and reload configuration with (yet) old `mod** $mod+Shift+c.
6. Persist changes
Make these changes persistent to have them on next reboot.
At the begninning of .config/i3/config
add (without double
quotes in its parameters):
exec --no-startup-id xmodmap /path/to/.Xmodmap
Final
Now you can use PrtScn
as the new modifier for i3
.
References
- Official user guide: https://i3wm.org/docs/userguide.html
- Full list of XF86 key codes: https://cgit.freedesktop.org/xorg/proto/x11proto/tree/XF86keysym.h
- Find out IP addresses from MACs in a Local Area NetworkMay 10, 2023
- Choose any key as the modifier in i3wm in 6 steps
- Adding a swap memory to Linux from command line in 6 stepsApril 2, 2020
- Free up space in Linux (Ubuntu)March 27, 2020
- Switch between languages in Linux. Write in multiple languages with same keyboard.March 21, 2020
- How to make Ubuntu display emojisFebruary 12, 2020
- Detect and mount USB devices in Linux from consoleJanuary 24, 2019
- How to make screencasts in Ubuntu LinuxJanuary 21, 2019
- Using i3 window manager in LinuxJanuary 7, 2019
- Setting Up A Fresh Linux ServerAugust 25, 2018
- How To Download A Website With Wget The Right WayJune 30, 2017
- Replicate Installed Package Selections From One Ubuntu System To AnotherApril 24, 2017
- Using Clamav Antivirus In UbuntuJanuary 25, 2017
- How to Type Spanish Characters, Accents and Symbols in LinuxJune 6, 2016
Ubuntu
- How to activate tap to click touchpad's feature in Ubuntu in 4 stepsMarch 4, 2021
- Difference between suspend and hibernate in Ubuntu and how to execute them from command lineApril 12, 2020
- Solving Google Chrome's gpu-process error message in Ubuntu LinuxJanuary 7, 2019
- Solving Google Chrome's secret service operation error message in Ubuntu LinuxJanuary 7, 2019
- Start Emacs In Ubuntu The Right WayJune 10, 2017
Unix Shell
- Connect to a Bluetooth device from command line in Ubuntu LinuxJune 23, 2020
- Add Infolinks Script To An Existing Website From Console With Sed CommandApril 4, 2017
- How to change all files permissions to 644 and directories to 755January 10, 2017
- Shell Redirect Output And Errors To The Null Device In BashDecember 9, 2016
- Prevent Running Of Duplicate Cron JobsDecember 8, 2016
- Delete All Backup Files Recursively In BashNovember 28, 2016
- Bash Script to Find Out If MySQL Is Running Or NotNovember 9, 2016
Articles
Subcategories
Except as otherwise noted, the content of this page is licensed under CC BY-NC-ND 4.0 . Terms and Policy.
Powered by SimpleIT Hugo Theme
·