i3

i3 is a dynamic tiling window manager inspired by wmii that is primarily targeted at developers and advanced users.

The stated goals for i3 include clear documentation, proper multi-monitor support, a tree structure for windows, and different modes like in vim.

Installation

i3 can be installed with the i3-wm package.

An i3 package group is also available. It includes the window manager, a screen locker and two programs which write a status line to i3bar through stdout.

Note: i3-wm conflicts with i3-gaps (a fork of i3 with gaps and other features) and by default i3-gaps will be installed.

Starting

From tty

Run i3 with xinit.

Display manager

i3-wm includes i3.desktop as Xsession which starts the window manager. enables logs (useful for debugging). integrates i3 into GNOME.

Usage

See the official documentation for more information, namely the i3 User's Guide.

Keybindings

In i3, commands are invoked with a modifier key, referred to as . This is (Mod1) by default, with (Mod4) being a popular alternative. Super is the key usually represented on a keyboard as a Windows icon, or on an Apple keyboard as a Command key.

See the i3 reference card and Using i3 for the defaults. See Keyboard bindings to add new shortcuts.

Users of non-Qwerty keyboard layouts may wish to circumvent the "configuration wizard" as described below.

If switching between multiple window managers or desktop environments, consider using sxhkd or another environment agnostic program to manage bindings. More information can be found in Keyboard shortcuts#Xorg.

Containers and layouts

i3 manages windows in a tree structure, with containers as building blocks. This structure branches with horizontal or vertical splits. Containers are tiled by default, but can be set to tabbed or stacking layouts, as well as made floating (such as for dialog windows). Floating windows are always on top.

See i3 Tree and Containers and the tree data structure for details.

Application launcher

i3 uses dmenu as an application launcher, which is bound by default to $mod+d. As it is an optional dependency dmenu must first be installed before this functionality can be used.

i3-wm contains i3-dmenu-desktop, a Perl wrapper for dmenu which uses desktop entries to create a list of all installed applications. Alternatively, the package can be used.

rofi is a popular dmenu replacement and more that can list desktop entries.

KRunner as application launcher in KDE Plasma/i3

It is possible to have i3 running alongside KDE Plasma as seen here: KDE#Use a different window manager

When running Plasma with , one can set KRunner as alternative application launcher with $mod+d by adding the following to the i3 config:

Configuration

See Configuring i3 for details. The rest of this article assumes the i3 configuration file to be in the folder .

Configuration wizard and alternative keyboard layouts

When i3 is first started, it offers to run the configuration wizard i3-config-wizard. This tool creates by rewriting a template configuration file in . It makes two modifications to the default template:

  1. It asks the user to choose a default modifier key, which it adds to the template as a single line, like ; and
  2. it replaces all bindcode lines with bindsym lines corresponding to the user's current keyboard layout.

Step 2 is designed to ensure that the four navigation shortcuts, , k, l and on a Qwerty keyboard, will be mapped to keysyms which have the same location, e.g. , , , on a Dvorak keyboard. The side-effect of this magic is that up to fifteen other keysyms may be remapped in ways which break the mnemonics - so that, for a Dvorak user, "restart" is bound to instead of , "split horizontally" is bound to instead of $mod1+h, and so on.

Therefore, users of alternate keyboard layouts who want straightforward key bindings, which match the bindings given in tutorials, may prefer to circumvent the "config wizard". This can be done by just copying into (or ~/.i3/config), and editing that file.

Note that a keycode-based configuration is also possible, e.g. for users who often switch between keyboard layouts, but want the i3 bindings to stay the same.

Autostart

Add an command in file to execute a command at startup. For example:

exec terminator

Using an command instead will ensure that the command is also run whenever i3 is restarted.

Alternatively, you can use XDG Autostart.

i3bar

In addition to showing workspace information, i3bar can act as an input for i3status or an alternative, such as those mentioned in the next section. For example:

See the Configuring i3bar for details.

i3bar alternatives

Some users may prefer panels such as those provided by conventional Desktop Environments. This can be achieved within i3 by launching the panel application of choice during startup.

For example, to use the Xfce panel (), add the following line anywhere in :

exec --no-startup-id xfce4-panel --disable-wm-check

i3bar can be disabled by commenting the section of , or defining a keybind to toggle the bar:

Replacements independent of the desktop environment are listed below:

i3status

Copy over the default configuration files to the home directory:

$ cp /etc/i3status.conf ~/.config/i3status/config

Not all plugins are defined in the default configuration and some configuration values may be invalid for your system, so they need to be updated accordingly. See i3status(1) for details.

i3status replacements

  • goi3bar i3status replacement written in Go. Configuration-file driven with several plugins, concurrency options, and rich plugin support.
https://github.com/denbeigh2000/goi3bar/ || goi3bar-gitAUR
  • Barista Barista is an i3status replacement written in Go.
https://github.com/soumya92/barista || not packaged? search in AUR

i3status wrappers

Iconic fonts in the status bar

Support for iconic fonts is built in since i3 version 4.20.

  • .
  • .

To combine fonts, define a font fallback sequence in your configuration file, separating fonts with like so:

~/.config/i3/config
bar {
  ...
  font pango:DejaVu Sans Mono, Icons 8
  ...
}

In accordance with pango syntax, font size is specified only once, at the end of the comma-separated list of font families. Setting a size for each font would cause all but the last font to be ignored.

Add icons to the format strings in using the unicode numbers given in the cheatsheets linked above. The input method will vary between text editors. For instance, to insert the "heart" icon (unicode number f004):

  • in various gui text editors (e.g. gedit, Leafpad) and terminals (e.g. GNOME Terminal, xfce4-terminal): Ctrl+Shift+u, ,
  • in Emacs: , , , ,
  • in Vim (while in insert mode): , uf004
  • in urxvt: while holding , type

Terminal emulator

By default when pressing it launches the which is a script that invokes a terminal. See i3-sensible-terminal(1) for the order terminals are invoked in.

To instead launch a terminal of choice, modify this line in :

bindsym $mod+Return exec i3-sensible-terminal

Alternatively, set the environment variable.

Disable title click

Add to not select a window when you click on its title frame. Useful if your default layout is tabbed and you often miss click i3's tabs instead of something in an application.

Tips and tricks

Jump to open window

  • wmfocus Focus and select windows in i3 and other window managers
https://github.com/svenstaro/wmfocus || wmfocus

Jump to urgent window

Add to :

bindsym $mod+x [urgent=latest] focus

Save and restore the window layout

From version 4.8, and onward i3 can save and restore workspace layouts. To do this, the following packages are needed: and perl-json-xs.

Save the current window layout of a single workspace

To save the current window layout, follow these steps:

  1. First, execute various commands to open windows in a preferred workspace and resize them if needed. Make sure to write down each executed command for each window.
  2. Now, in a new workspace, open a terminal and run the following: where N is the number of the preferred workspace. This will save the current layout of workspace N to the file .
  3. The newly created file needs to be edited. This may be done automatically with the following command:

Restore the window layout of the workspace

There are two ways to restore the layout of the workspace: by writing a script, or by editing to automatically load the layout. In this section only the first case will be considered, refer to the official documentation for the second case.

To restore the saved layout in the previous section, write a file named load_layout.sh with the following contents:

  • The starting lines:

where M is the number of the workspace in which you would like to load the previously saved layout and N is the number of workspaces saved in the previous section.

  • And the commands used in the previous section to get the preferred windows, but enclosed in parentheses and with an ampersand appended before the last parentheses.

For example, if the saved layout contained three windows:

Then set the file as executable. Finally, the layout of workspace N can be loaded onto to workspace M by running:

$ ~/load_layout.sh
Note: If the above script does not work properly, refer to the official documentation. The swallows sections of ~/.config/i3/workspace_N.json needs to be manually edited.

Scratchpad containers

By default, scratchpads only contain a single window. However, containers can also be made a scratchpad.

Create a new container (for example, ), split it () and create another container. Focus the parent (), split in the opposite direction (), and create a container again.

Focus the first container (with focus parent as needed), make the window floating (Mod+Shift+Space), and move it to the scratchpad (). You can now split containers to preference.

See also for multiple scratchpads.

Screensaver and power management

With Power management#xss-lock you can register a screenlocker for your i3 session. The option with xautolock locks the screen after a given time period:

xautolock -time 10 -locker "i3lock -i background_image.png" &

A systemd service file can be used to lock the screen before the system is being sent to sleep or hibernation state. See Power management#Suspend/resume service files. Note that i3lock requires the type of service to be forking.

See also DPMS.

Another option is to use with or any other screensaver. xidlehook is a xautolock replacement written in Rust, but with a few extra features. This includes the option to disable locking when audio is playing or when the screen is in full screen. The option is given in seconds:

xidlehook --not-when-audio --not-when-fullscreen --timer 360 "betterlockscreen -l dim" "" &

Shutdown, reboot, lock screen

Key combinations for shutdown, reboot and screenlock can be added to . The below example assumes you have installed to allow unprivileged users to run power management commands.

Once completed, you will be presented with a prompt whenever you press . For more complex behavior, use a separate script, and refer to it in the mode.

For a list of alternative screen lockers, see List of applications/Security#Screen lockers.

Swallow terminal window

Similarly to dwm, i3 can "swallow" the current terminal window with the new GUI window launched from it. This can be done through the use of the package.

For example, to let mpv's window swallow the originating terminal:

$ swallow mpv video.mp4

Alternatively, terminal swallowing can be simulated by using a tabbed or stacked container in order to hide the terminal window when you are not using it. However, this comes with the drawback of always having a window list at the top of the container.

External displays manual management

Thanks to xrandr there are many ways to easily manage systems displays. The below example integrates it in the i3 configuration file, and behave as the Power Management section above.

Here a laptop with both VGA and HDMI outputs will use a menu selection to switch them On/Off:

## Manual management of external displays
# Set the shortcuts and what they do
set $mode_display Ext Screen (v) VGA ON, (h) HDMI ON, (x) VGA OFF, (y) HDMI OFF
mode "$mode_display" {
    bindsym v exec --no-startup-id xrandr --output VGA1 --auto --right-of LVDS1, mode "default"
    bindsym h exec --no-startup-id xrandr --output HDMI1 --auto --right-of LVDS1, mode "default"
    bindsym x exec --no-startup-id xrandr --output VGA1 --auto --off, mode "default"
    bindsym y exec --no-startup-id xrandr --output HDMI1 --auto --off, mode "default"

    # back to normal: Enter or Escape
    bindsym Return mode "default"
    bindsym Escape mode "default"
}
# Declare here the shortcut to bring the display selection menu
bindsym $mod+x mode "$mode_display"

Any window that is still open in a switched Off display will automatically come back to the remaining active display.

The simplest way to determine names of your devices is to plug the device you wish to use and run:

$ xrandr --query

which will output the available, recognized devices and their in-system names to set your configuration file appropriately.

Refer to the xrandr page or man page for the complete list of available options, the i3 userguide and/or the i3 FAQ on reddit for more info.

Tabbed or stacked web-browsing

Some web-browsers intentionally do not implement tabs, since managing tabs is considered to be the task of the window manager, not the task of the browser.

To let i3 manage your tab-less web-browser, in this example for uzbl, add the following line to your

for_window [class="Uzbl-core"] focus child, layout stacking, focus

This is for stacked web browsing, meaning that the windows will be shown vertically. The advantage over tabbed browsing is that the window-titles are fully visible, even if a lot of browser windows are open.

If you prefer tabbed browsing, with windows in horizontal direction ('tabs'), use

for_window [class="Uzbl-core"] focus child, layout tabbed, focus

Workspace variables

As workspaces are defined multiple times in i3, assigning workspace variables can be helpful. For example:

set $WS1 term
set $WS2 web
set $WS3 misc
set $WS4 media
set $WS5 code

Then replace workspace names with their matching variables:

bindsym $mod+1          workspace $WS1
...
bindsym $mod+Shift+1    move container to workspace $WS1

See Changing named workspaces for more information.

Correct handling of floating dialogs

While dialogs should open in floating mode by default , many still open in tiling mode. To change this behaviour, check the dialog's WM_WINDOW_ROLE with and add the correct rules to ~/.i3/config (using pcre syntax):

for_window [window_role="pop-up"] floating enable
for_window [window_role="task_dialog"] floating enable

You can also use title rules and regular expressions:

for_window [title="Preferences$"] floating enable

or :

for_window [class="(?i)mplayer"] floating enable

Network Download/Upload speed in statusbar

You might adapt this upstream script. For that,

  • rename both network cards according to your system (use )
  • find them on /sys/devices then replace them appropriately:
$ find /sys/devices -name network_interface

Now, just save the script in a suitable place (for example ) and point your status program to it.

Automatically switch horizontal / vertical window split orientation

The package can be used for automatic switching horizontal / vertical window split orientation resulting in a similar behavior to the spiral tiling of bspwm. After installation add the following to your and reload i3.

exec_always --no-startup-id autotiling

Troubleshooting

General

In many cases, bugs are fixed in the development versions and , and upstream will ask to reproduce any errors with this version. See also Debugging/Getting traces#Compilation options.

New installation displays only garbled text

Make sure that you installed a set of TrueType fonts after installation.

Buttons in the i3 message bar do not work

Buttons such as "Edit config" in call , so make sure your Terminal emulator is recognized by i3.

Faulty line wraps in tiled terminals

i3 v4.3 and higher ignore size increment hints for tiled windows . This may cause terminals to wrap lines prematurely, amongst other issues. As a workaround, make the offending window floating, before tiling it again.

Mouse cursor remains in waiting mode

When starting a script or application which does not support startup notifications, the mouse cursor will remain in busy/watch/clock mode for 60 seconds.

To solve this for a particular application, use the --no-startup-id parameter, for example:

exec --no-startup-id ~/script
bindsym $mod+d exec --no-startup-id dmenu_run

To disable this animation globally, see Cursor themes#Create links to missing cursors.

Unresponsive key bindings

Some tools such as scrot may not work when used with a regular key binding (executed after key press). In those cases, execute commands after key release with the argument :

bindsym --release Print exec --no-startup-id scrot
bindsym --release Shift+Print exec --no-startup-id scrot -s

Tearing

i3 does not properly implement double buffering hence tearing or flickering may occur. See picom.

Tray icons not visible

The directive may require setting a primary output with xrandr, specifying the output explicitly or simply removing this directive. See Xrandr for details. The default configuration created by i3-config-wizard no longer adds this directive to the configuration from i3 4.12.

Default workspace for Spotify

To assign a default workspace for spotify windows one cannot use the standard route with and should rather use a for_window command, such as

To ensure for_window does not move the window if already in , one can instead use .

See also

Arch Linux Forums

Screencasts

This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.