Table of Contents

Keyboard Layout in i3

i3 Window Manager

i3wm does not come with stock Slackware. If you want to install this extremely configurable tiling window manager, please visit SlackBuilds. Make sure you also install i3status, which will let you display all sorts of useful information in a panel.

Setting the Keyboard Layout

i3 does not come with any built-in keyboard setting mechanism. The setxkbmap command, however, does the job well. If you've set the keyboard layout system-wide and do not need to switch between layouts, you do not need to do anything. If you'd like to set the layout just for i3, you can edit its .xinitrc file. If you change a graphical environment often and you do not want the keymap to be overwritten, you need to modify /etc/X11/xinit/xinitrc.i3.

# nano /etc/X11/xinit/xinitrc.i3

Just before the Start i3 section you can specify the desired keymap (eg. gb):

setxkbmap gb

Save the file and run (as a standard user) xwmconfig and choose i3 to copy the xinitrc file to your home directory. If you are in X, you might need to restart it.

Changing the Keyboard Layout

If you need to switch between different layouts, you can map some keybindings to perform those functions.

1. Open the i3 config file

nano ~/.i3/config

2. Add the following (it's just an example):

Assign Mod4 to the Microsoft key (I use the Microsoft key a lot to avoid clashes with default i3 keybindings):

set $ms Mod4

bindsym $ms+d exec setxkbmap de
bindsym $ms+g exec setxkbmap gb

Now MS+D and MS+G let me switch between the UK and German keyboard layouts.

If you usually switch between two keyboard layouts and you don't need to display the current layout in the status bar, you might also place the following code in your ~/.i3/config file:

setxkbmap -layout de,gb
setxkbmap -option 'grp:ctrl_alt_toggle'

This will let you toggle between the two layouts using Ctrl+Alt.

Displaying the Active Layout in the Panel

i3status comes with a lot of built-in functions. Unfortunately, the current keyboard layout is not one of them. For that reason, you need to write a short script to display the layout in the panel. The default i3status invocation is as follows:

bar {
status_command i3status
}

Here all the built-in functionality is configured in ~/.i3status.conf. We want to add some more on top of that and change it to: