Difference between revisions of "I3"

From ArchWiki
Jump to: navigation, search
(Run i3)
(Volume manager: this information should go into a wiki article about pa-applet, as pa-applet can be used in any other wm, and it is not specific to i3)
Line 212: Line 212:
  path = "/sys/class/thermal/thermal_zone0/temp"
  path = "/sys/class/thermal/thermal_zone0/temp"
=== Volume manager ===
To enable easy management of your system volume, you can install a volume manager applet such as {{AUR|pa-applet-git}} from the [[AUR]].  This should also allow you to use your keyboards volume up, volume down, and mute keys as well as using the applet directly to manage your volume.  Once it is installed add the following line to your {{ic|~/.i3/config}} to auto start the applet:
exec /usr/bin/pa-applet
or configure it manually adding these lines:
bindsym XF86AudioMute exec "pactl set-sink-mute SINK toggle"
bindsym XF86AudioRaiseVolume exec "pactl set-sink-volume SINK +1%"
bindsym XF86AudioLowerVolume exec "pactl set-sink-volume SINK -- -1%"
where {{ic|SINK}} has to be the first or second column from {{ic|$ pactl list short sinks}} list for your desired device.
A trick to get the status bar to refresh immediately after changing the volume is to send it the USR1 signal (note the lines are using {{ic|amixer}} instead of {{ic|pactl}}):
bindsym XF86AudioMute exec "amixer set Master toggle && killall -USR1 i3status"
bindsym XF86AudioRaiseVolume exec "amixer set Master 5%+ && killall -USR1 i3status"
bindsym XF86AudioLowerVolume exec "amixer set Master 5%- && killall -USR1 i3status"
=== Workspace names ===
=== Workspace names ===

Revision as of 18:04, 30 April 2014

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

Clients (windows) are organized in a tree data structure within containers. The tree branches via horizontal or vertical splits, and containers can also be set to tabbed or stacked layouts. Floating windows are available for corner cases that don't mix well with tiling, and remain on a separate layer above the tiled windows.


Install the i3 package group from the official repositories, which includes: i3-wm, the window manager; i3status, a package to write a status line to i3bar through stdout; and i3lock, an improved screenlocker.

Additional packages are available in the Arch User Repository. Install i3-gitAUR for the development version.

Install i3-gnomeAUR to add GNOME and X-sessions with i3 running as the window manager. An Xsession starting just the window manager is included in i3.

Run i3 from xinitrc

To run i3 from xinitrc edit your ~/.xinitrc and add:

exec i3

Now you can start i3 by running startx from a tty.

If you want i3 to log its output (useful for debugging), add this line to ~/.xinitrc:

exec i3 -V >> ~/.i3/i3log 2>&1

If you use the Nvidia binary driver <302.17 you need to add the --force-xinerama flag to ~/.xinitrc. A detailed explanation can be found at i3wm.org.

exec i3 --force-xinerama

If you have trouble with mapping keys (ie ; as semicolon), use xorg-xev or see Extra Keyboard Keys.

$ xev | grep -A2 --line-buffered '^KeyRelease' | sed -n '/keycode /s/^.*keycode \([0-9]*\).* (.*, \(.*\)).*$/\1 \2/p'


See the official documentation on this subject for more information: i3 User’s Guide

In i3, commands are invoked using a modifier key, which is referred to as $mod. This is the Alt key (Mod1) by default, with the Windows key (Mod4) being a popular alternative.

Default keybindings

(Many thanks for Funtoo Linux team for the excellent wiki (http://www.funtoo.org/I3_Tiling_Window_Manager))

Key Command
$mod + Enter Open terminal
$mod + A Focus Parent
$mod + S Stacked Layout
$mod + W Tabbed Layout
$mod + E Default Layout
$mod + SpaceBar Focus tiling/floating
$mod + D dmenu
$mod + H Split Horizontal
$mod + V Split Vertically
$mod + J Left
$mod + K Down
$mod + L Up
$mod + ; Right
$mod + Shift + Q Kill window
$mod + Shift + E Exit i3
$mod + Shift + C Reload i3config without restarting
$mod + Shift + R Restart i3 (reloads i3config without exiting i3)
$mod + Shift + J Move left
$mod + Shift + K Move down
$mod + Shift + L Move up
$mod + Shift + : Move right
$mod + Shift + SpaceBar Toggle tiling/floating

Application launcher

i3 currently uses dmenu as a application launcher, which is bound by default to $mod+d.

By default i3-dmenu-desktop is used as a wrapper for dmenu. i3-dmenu-desktop creates a list of all installed applications via their .desktop files. There is a rewrite of this perl script called j4-dmenu-desktop-gitAUR, which is a near-drop-in replacement for the script shipped with i3, but much faster.


Status bar

The internal status bar, i3-wsbar, was deprecated and replaced by i3bar in i3 v4.0.

New method: i3bar

Unlike i3-wsbar, which requires dzen2, i3bar does not have any dependencies other than i3-wm. It can be used to view information generated by conky or i3status. For example (as of version 4.1):

bar {
    output            LVDS1
    status_command    i3status
    position          top
    mode              hide
    workspace_buttons yes
    tray_output       none
    font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1

    colors {
        background #000000
        statusline #ffffff

        focused_workspace  #ffffff #285577
        active_workspace   #ffffff #333333
        inactive_workspace #888888 #222222
        urgent_workspace   #ffffff #900000

For further information see the Configuring i3bar section of the official User Guide.

Alternatives to i3status

  • i3blocks - Define the status line blocks with shell commands. It handles clicks, signals and different time intervals, in respect to the i3bar protocol. (AUR: i3blocksAUR)
  • i3pystatus - extensible i3status replacement with many modules and very flexible configuration. Multi-threaded and lock-up free. (AUR: i3pystatus-gitAUR)
  • i3situation – a pure python 3 replacement with features provided by multithreaded plugins.
  • py3status – an extensible i3status wrapper written in python
  • dzen – often used with conky to create completely custom status bars
  • j4status - j4status provides a status line using several plugin to retrieve information from your computer. j4status is a part of the j4tools - tools set to use with i3.
  • h2status - trivial bash wrapper to i3status that nevertheless allows to conveniently write custom json entries, handle click events and asynchronously update the status bar.

Panel alternatives to status bar

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 the XFCE panel, add the following line to ~/.i3/config:

exec --no-startup-id xfce4-panel
Note: Panel features that are specific to the Desktop Environment (e.g., widgets for managing workspaces and sessions) will not work, though the normal i3 functionality will be unaffected.

Disabling i3bar is as simple as commenting out the bar{ } section of ~/.i3/config.

Iconic fonts in the status bar

There is a patch for i3bar to make it properly support icons, but here we'll see how to take advantage of a couple of very complete iconic font sets in order to get really nice looking monochromatic icons in your status bar. Some ttf iconic font sets that are currently available in the AUR are:

  • ttf-font-awesomeAUR that has a cheatsheet showing the Unicode point for each glyph here [1].
  • ttf-font-iconsAUR provides the Icons font set, a non-overlapping and consistently sized mix of Awesome and Ionicons. This not only avoids the overlapping between Awesome and Ionicons but also some minor overlapping between the usual DejaVu Sans and Awesome. All in all it provides a ready to use solution for your status bar including lots of icons. The cheatsheet is here [2].

Then you can combine these fonts by defining a font fallback sequence in your ~/.i3/config:

bar {
  font pango:DejaVu Sans Mono, Icons 8

Notice that you have to first list the comma separated font families and then add only one size specification at the end of the string. Don't set a size for each family (even if it happens to be the same size for every family) and don't try to get the same result using multiple font directives, as the vertical alignments and heights of the different components of the i3bar will be wrong in unexpected ways. The correct pango descriptor syntax is as shown above.

Finally, you will have to enter the iconic glyphs into the format strings in ~/.i3status.conf. For this, use the unicode numbers given in the cheatsheets linked above. For example, if you're using vim you can type <C-v>uXXXX, where XXXX is the unicode hexadecimal number for the glyph.

Quickly jumping to open window

  • quickswitch-for-i3 – A Python utility to quickly change to and locate windows in i3
  • i3-wm-scripts – search for and jump to windows with particular names matching regexp
  • winmenupy launches dmenu with a list of clients, sorted after workspaces. Selecting a client jumps to that window.


First we need to copy over the default configuration files that we will be working with to our home directory.

$ cp /etc/i3status.conf ~/.i3status.conf
Tip: The example configuration file uses eth0 and wlan0 as interface names, see Network configuration#Device names if they do not match with your system.

Temperature status

If you would like to add your CPU temperature to the i3status bar simply add these lines to ~/.i3status.conf:

order += "cpu_temperature 0"
cpu_temperature 0 {
        format = "T: %degrees °C"
    max_threshold = 65
        path = "/sys/devices/platform/coretemp.0/temp1_input"

If the temperature column complains that it cannot get the temperature value then change the path line to:

path = "/sys/class/thermal/thermal_zone0/temp"

Workspace names

Although it is not required, many people prefer naming frequently used workspaces. First you need to determine which monitor you want the workspace to open to. Simply type xrandr into a terminal and it will show you the available display ports. Some common ones are LVDS1 for laptops or VGA1, HDMI1, HDMI2, etc for external monitors. If you are using Xinerama instead use the outputs xinerama-0, xinerama-1, etc. Add your workspace names to ~/.i3/config You also need to modify the corresponding lines to switch to your workspaces as well as moving focused containers to those workspaces.

# Workspace names
workspace "1:Web" output LVDS1
workspace "2:Mail" output LVDS1
workspace "3:Irc" output LVDS1
workspace "4:Shell" output LVDS1
# switch to workspace
bindsym $mod+1 workspace 1:Web
bindsym $mod+2 workspace 2:Mail
bindsym $mod+3 workspace 3:Irc
bindsym $mod+4 workspace 4:Shell
# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace 1:Web
bindsym $mod+Shift+2 move container to workspace 2:Mail
bindsym $mod+Shift+3 move container to workspace 3:Irc
bindsym $mod+Shift+4 move container to workspace 4:Shell

Launching programs on specific workspaces

To maximize efficiency you can setup certain programs to automatically launch to a specific workspace. This can be accomplished one of two ways. You could use the assign command so when you manually launch a program it is directed to a the workspace you assigned. An example would be:

# Assign URxvt terminals to workspace 2
assign [class="URxvt"] 2

Or if you have renamed the workspaces like the above examples then you must set the new workspace name instead of the number:

# Assign URxvt terminals to workspace 4:Shell
assign [class="URxvt"] 4:Shell
Note: To be able to determine the class, title, instance, etc of an open window you can use the tool xprop by installing the package xorg-xprop from the Extra repository.

Alternatively you can change to your target workspace with i3-msg then have your frequently used programs start automatically with the exec command:

exec --no-startup-id i3-msg 'workspace 1:Web; exec /usr/bin/firefox' 
exec --no-startup-id i3-msg 'workspace 2:Mail; exec urxvt -name Mail -e /usr/bin/mutt'
exec --no-startup-id i3-msg 'workspace 3:Irc; exec /usr/bin/urxvt -name irssi -e /usr/bin/irssi'
exec --no-startup-id i3-msg 'workspace 4:Shell; exec /usr/bin/urxvt'

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 ~/.i3/config

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

Terminal emulator

By default when you press $mod+Return it launches the i3-sensible-terminal which is a script that invokes a terminal. It attempts to start one of these terminals in the following order:

You can force it to launch your terminal of choice by modifying this line

bindsym $mod+Return exec i3-sensible-terminal


Having a scratchpad to jot down or paste notes quickly is very handy! i3 has a feature that allows you to move a window to a scratchpad workspace. Basically it will be hidden from view until you recall it with the scratchpad show command. To send a focused window to the scratchpad with $mod+Shift+minus or to recall it with $mod+minus enter these lines into your ~/.i3/config

# Make the currently focused window a scratchpad
bindsym $mod+Shift+minus move scratchpad

# Show the first scratchpad window
bindsym $mod+minus scratchpad show

You can start your favorite editor (ie Gedit, vim, nano, etc) on startup and have it automatically moved to the scratchpad workspace to quickly recall it when needed. The following example when placed in ~/.i3/config shows how you can start the urxvt terminal, have it launch the nano editor, and then move it to the scratchpad:

# starting a specially named term automatically 
exec --no-startup-id urxvt -name scratchpad -e /usr/bin/nano
# move this to scratchpad, if active
for_window [class="URxvt" instance="scratchpad"] move scratchpad

Themes and Colorschemes

The configuration file allows for customization of the colors of window decorations, but the syntax for doing so does not make it practical to create or share themes. There are several projects that can make this easier which include a variety of user-contributed themes that can be applied to your config.

  • i3-style modifies your config in place from a theme stored in a JSON object designed for frequently tweaking or changing a colorscheme (available as nodejs-i3-styleAUR in the AUR).
  • j4-make-config merges your base config with one of the user-contributed themes or your own custom config parts, for example host-specfic configuration, allowing flexible and dynamic customization of the configuration. It is available in the AUR as j4-make-config-gitAUR.

Shutdown, reboot, lock screen

As there are no Shutdown, Reboot, or Lock Screen buttons, we can add some hotkey combinations to help us out. First we need to create this script and save it as i3exit. Remember to make it executable with chmod +x and to place it somewhere in your $PATH. This script assumes that you have polkit installed to allow unprivileged users to run power management commands.

lock() {

case "$1" in
        i3-msg exit
        lock && systemctl suspend
        lock && systemctl hibernate
        systemctl reboot
        systemctl poweroff
        echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}"
        exit 2

exit 0

Now add the following lines to your ~/.i3/config Once completed you will be presented with a prompt whenever you press $mod+pause.

set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown
mode "$mode_system" {
    bindsym l exec --no-startup-id i3exit lock, mode "default"
    bindsym e exec --no-startup-id i3exit logout, mode "default"
    bindsym s exec --no-startup-id i3exit suspend, mode "default"
    bindsym h exec --no-startup-id i3exit hibernate, mode "default"
    bindsym r exec --no-startup-id i3exit reboot, mode "default"
    bindsym Shift+s exec --no-startup-id i3exit shutdown, mode "default"  

    # back to normal: Enter or Escape
    bindsym Return mode "default"
    bindsym Escape mode "default"
bindsym $mod+Pause mode "$mode_system"

Merge-arrows-2.pngThis article or section is a candidate for merging with List of applications/Security#Screen lockers.Merge-arrows-2.png

Notes: The following does not belong here, it's not like that i3lock can be used only with i3 (Discuss in Talk:I3#)

There are some alternatives to i3lock, which includes blur effects:

Screensaver and power management

You can use DPMS to blank your screen or to suspend/poweroff your monitor. Adding the following line to your ~/.i3/config will suspend your monitor after 10 minutes.

exec --no-startup-id xset dpms 600

With xss-lockAUR you can register a screenlocker for your i3 session. xss-lock subscribes to the systemd-events suspend, hibernate, lock-session, and unlock-session with appropriate actions (run locker and wait for user to unlock or kill locker). It also reacts to the X screensaver and runs or kills the locker in response to the x-server signals. Start xss-lock in your autostart like this:

xss-lock -- i3lock -i background_image &


Mouse cursor remains in waiting mode

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

To fix this issue, add --no-startup-id parameter to that particular exec command, for example:

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

See also

Arch Linux Forums