Configuring i3

As a developer, focus is key. An environment with minimal distractions is conducive to productivity and window managers offer minimalist user interfaces in place of the traditional desktop environment. i3 on Ubuntu will be discussed here but there are alternate window managers such as dwm and awesome. i3 can be installed with the following command:

# install i3
sudo apt-get install i3

i3 Configuration

i3’s configuration should be created in ~/.config/i3/config. Here is the default configuration from the man page:

# i3 config file (v4)

# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
# This font is widely installed, provides lots of unicode glyphs, right-to-left
# text rendering and scalability on retina/hidpi displays (thanks to pango).
font pango:DejaVu Sans Mono 8
# Before i3 v4.8, we used to recommend this one as the default:
# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
# The font above is very space-efficient, that is, it looks good, sharp and
# clear in small sizes. However, its unicode glyph coverage is limited, the old
# X core fonts rendering does not support right-to-left and this being a bitmap
# font, it doesn't scale on retina/hidpi displays.

# use Mouse+Mod1 to drag floating windows to their wanted position
floating_modifier Mod1

# start a terminal
bindsym Mod1+Return exec /usr/bin/urxvt

# kill focused window
bindsym Mod1+Shift+q kill

# start dmenu (a program launcher)
bindsym Mod1+d exec /usr/bin/dmenu_run

# change focus
bindsym Mod1+j focus left
bindsym Mod1+k focus down
bindsym Mod1+l focus up
bindsym Mod1+semicolon focus right

# alternatively, you can use the cursor keys:
bindsym Mod1+Left focus left
bindsym Mod1+Down focus down
bindsym Mod1+Up focus up
bindsym Mod1+Right focus right

# move focused window
bindsym Mod1+Shift+j move left
bindsym Mod1+Shift+k move down
bindsym Mod1+Shift+l move up
bindsym Mod1+Shift+semicolon move right

# alternatively, you can use the cursor keys:
bindsym Mod1+Shift+Left move left
bindsym Mod1+Shift+Down move down
bindsym Mod1+Shift+Up move up
bindsym Mod1+Shift+Right move right

# split in horizontal orientation
bindsym Mod1+h split h

# split in vertical orientation
bindsym Mod1+v split v

# enter fullscreen mode for the focused container
bindsym Mod1+f fullscreen toggle

# change container layout (stacked, tabbed, default)
bindsym Mod1+s layout stacking
bindsym Mod1+w layout tabbed
bindsym Mod1+e layout default

# toggle tiling / floating
bindsym Mod1+Shift+space floating toggle

# change focus between tiling / floating windows
bindsym Mod1+space focus mode_toggle

# focus the parent container
bindsym Mod1+a focus parent

# focus the child container
#bindsym Mod1+d focus child

# switch to workspace
bindsym Mod1+1 workspace 1
bindsym Mod1+2 workspace 2
# ..

# move focused container to workspace
bindsym Mod1+Shift+1 move workspace 1
bindsym Mod1+Shift+2 move workspace 2
# ...

# reload the configuration file
bindsym Mod1+Shift+c reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym Mod1+Shift+r restart
# exit i3 (logs you out of your X session)
bindsym Mod1+Shift+e exit

# display workspace buttons plus a statusline generated by i3status
bar {
      status_command i3status
}

Customization

Customizations should be made in the ~/.config/i3/config file.

i3 Status Bar

bar {
  status_command i3status
  font pango:Hack, FontAwesome 10
}

status_command receives json and parses output to the status bar in i3. Lemonbar is another example of a status bar application that could be in place of i3status.

Setting a Background

feh can be used to set the background for i3. Install feh with:

# install feh to managed backgrounds
sudo apt-get install feh

With feh installed, add the following line to i3’s config

exec --no-startup-id feh --bg-scale /path/to/awesome/wallpaper.png

Audio Keys

The following configurations can be added to enable audio keys.

bindsym XF86AudioLowerVolume    exec $psst pactl set-sink-volume @DEFAULT_SINK@ -5% && pactl set-sink-mute @DEFAULT_SINK@ 0 $update
bindsym XF86AudioRaiseVolume    exec $psst pactl set-sink-volume @DEFAULT_SINK@ +5% && pactl set-sink-mute @DEFAULT_SINK@ 0 $update
bindsym XF86AudioMute           exec $psst pactl set-sink-mute @DEFAULT_SINK@ toggle $update

Screen Brightness

The following configurations can be added to enable brightness keys.

bindsym XF86MonBrightnessDown   exec xbacklight -dec 10
bindsym XF86MonBrightnessUp     exec xbacklight -inc 10

The following configurations can be added to enable print screen. scrot is used in this example. Be sure to install scrot when using this configuration.

# install scrot if not installed
sudo apt-get install scrot

# ~/.config/i3/config
# Print screen focused window
bindsym Print exec scrot -u '%Y%m%d_%H%M%S.png' -e 'mv $f ~/Pictures/shots/'

# Print screen entire view
bindsym $mod+Print exec scrot '%Y%m%d_%Ho%M%S.png' -e 'mv $f ~/Pictures/shots/'

Configuring i3status

i3status handles the status bar output. The config file for i3status is located in ~/.i3status.conf. Here is an example config that uses FontAwesome.

# i3status configuration file.
# see "man i3status" for documentation.

# It is important that this file is edited as UTF-8.
# The following line should contain a sharp s:
# ß
# If the above line is not correctly displayed, fix your editor first!

general {
        colors = true
        interval = 5
}

order += "disk /"
order += "volume master"
order += "wireless _first_"
order += "battery 1"
order += "load"
order += "tztime local"

wireless _first_ {
        format_up = " (%essid - %quality) %ip"
        format_down = "down"
}

volume master {
        format = " %volume"
        format_muted = " (%volume)"
        device = "pulse:1"
        mixer = "Master"
        mixer_idx = 0
}

battery 1 {
        format = "%status %percentage %remaining"
        status_bat = ""
        status_chr = ""
        status_full = ""
        low_threshold = 30
        threshold_type = percentage
        integer_battery_capacity = true
        color_good = "#0000FF"
}

run_watch DHCP {
        pidfile = "/var/run/dhclient*.pid"
}

run_watch VPN {
        pidfile = "/var/run/vpnc/pid"
}

tztime local {
        format = " %h %d, %Y %I:%M:%S"
}

load {
        format = " %1min"
}

disk "/" {
        format = " %avail"
}

Conclusion

i3 is relatively straight forward to setup given the user reads the man page. It will be interesting to dive into research for other status bars, but for now it’s time to get back to work.