i3 Window Manager

This post is a reminder for my i3wm configuration. I like very much the minimalism of this tiling windown manager.
I use Manjaro as my Linux Distro so if you are using another distro, something will not work correctly.

Prerequisites

  • i3 the main actor
  • arandr is a tool to let you configure all of your screens with a GUI
  • xev is a tool used to get the key code from your keyboard
  • xprop is a tool used to get the class name of applications
  • rofi is a tool used to list your applications before launch them

To install i3 just execute:

sudo pacman -S i3-wm i3lock i3status

To install the other tools execute: sudo pacman -S arandr xev xprop rofi

To setup the correct monitor resolution you have to run arandr and save the configuration file. The default path is: $HOME/.screenlayout/[your_conf.sh] . Just remember to update the i3 config file to reflect the name of your script. I use 2 scripts:

  1. singlemonitor.sh -> for my laptop monitor.
  2. multimonitor.sh -> when using multi-monitor setup.

The singlemonitor.sh is being executed on login phase 'cause my laptop's panel is a 4k resolution so i set it to 1920x1080.

This is the main i3 configuration file located at: /home/[user]/.config/i3/config

# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#

# i3 config file (v4)
#
# Please see https://i3wm.org/docs/userguide.html for a complete reference!

set $mod Mod4

# Custom colors
set $base00 #101218
set $base01 #1f222d
set $base02 #252936
set $base03 #7780a1
set $base04 #C0C5CE
set $base05 #d1d4e0
set $base06 #C9CCDB
set $base07 #ffffff
set $base08 #ee829f
set $base09 #f99170
set $base0A #ffefcc
set $base0B #a5ffe1
set $base0C #97e0ff
set $base0D #97bbf7
set $base0E #c0b7f9
set $base0F #fcc09e

# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
font pango:System San Francisco Dispaly 10

# 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

# The combination of xss-lock, nm-applet and pactl is a popular choice, so
# they are included here as an example. Modify as you see fit.

# xss-lock grabs a logind suspend inhibit lock and will use i3lock to lock the
# screen before suspend. Use loginctl lock-session to lock your screen.
exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock --nofork

# NetworkManager is the most popular way to manage wireless networks on Linux,
# and nm-applet is a desktop environment-independent system tray GUI for it.
exec --no-startup-id nm-applet

# Autostart applications
# Default resolution when single monitor
exec --no-startup-id $HOME/.screenlayout/single_monitor.sh
# Start dropbox
exec --no-startup-id /usr/bin/dropbox
# Start jetbrains toolbox
exec --no-startup-id /usr/bin/jetbrains-toolbox
# Start keepassxc
exec --no-startup-id /usr/bin/keepassxc

# Use pactl to adjust volume in PulseAudio.
set $refresh_i3status killall -SIGUSR1 i3status
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% && $refresh_i3status
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% && $refresh_i3status
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status
bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status

#brightness control
bindsym XF86MonBrightnessUp exec xbacklight -inc 20
bindsym XF86MonBrightnessDown exec xbacklight -dec 20

# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod

# start a terminal
bindsym $mod+Return exec gnome-terminal

# kill focused window
bindsym $mod+Shift+q kill

# start dmenu (a program launcher)
#bindsym $mod+d exec --no-startup-id dmenu_run
# A more modern dmenu replacement is rofi:
bindsym $mod+d exec "rofi -modi drun,run -show drun"
# There also is i3-dmenu-desktop which only displays applications shipping a
# .desktop file. It is a wrapper around dmenu, so you need that installed.
# bindcode $mod+40 exec --no-startup-id i3-dmenu-desktop

# Custom keybindings
# configure three monitors
bindsym $mod+Shift+m exec "$HOME/.screenlayout/multi_monitor.sh"

# change focus
bindsym $mod+j focus left
bindsym $mod+k focus down
bindsym $mod+l focus up
bindsym $mod+ograve focus right

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

# move focused window
bindsym $mod+Shift+j move left
bindsym $mod+Shift+k move down
bindsym $mod+Shift+l move up
bindsym $mod+Shift+ograve move right

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

# split in horizontal orientation
bindsym $mod+h split h

# split in vertical orientation
bindsym $mod+v split v

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

# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split

# toggle tiling / floating
bindsym $mod+Shift+space floating toggle

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

# focus the parent container
bindsym $mod+a focus parent

# focus the child container
#bindsym $mod+d focus child

# Custom keybinding
bindsym $mod+Shift+Print exec /usr/bin/gnome-screenshot

# Define names for default workspaces for which we configure key bindings later on.
# We use variables to avoid repeating the names in multiple places.
set $ws1 "1:Slack "
set $ws2 "2:Firefox "
set $ws3 "3:Google "
set $ws4 "4:Terminals "
set $ws5 "5:Whatever "
set $ws6 "6:TextEditors "
set $ws7 "7:IDEs "
set $ws8 "8:Files"
set $ws9 "9"
set $ws10 "10:Music "

# switch to workspace
bindsym $mod+1 workspace $ws1
bindsym $mod+2 workspace $ws2
bindsym $mod+3 workspace $ws3
bindsym $mod+4 workspace $ws4
bindsym $mod+5 workspace $ws5
bindsym $mod+6 workspace $ws6
bindsym $mod+7 workspace $ws7
bindsym $mod+8 workspace $ws8
bindsym $mod+9 workspace $ws9
bindsym $mod+0 workspace $ws10

# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace $ws1
bindsym $mod+Shift+2 move container to workspace $ws2
bindsym $mod+Shift+3 move container to workspace $ws3
bindsym $mod+Shift+4 move container to workspace $ws4
bindsym $mod+Shift+5 move container to workspace $ws5
bindsym $mod+Shift+6 move container to workspace $ws6
bindsym $mod+Shift+7 move container to workspace $ws7
bindsym $mod+Shift+8 move container to workspace $ws8
bindsym $mod+Shift+9 move container to workspace $ws9
bindsym $mod+Shift+0 move container to workspace $ws10


# Open applications to dedicated workspace
# To get the class name of the application execute `xprop` on a terminal window
# and put the cross on the title of the window that you want to get the class name from,
# the output will be printed in the terminal window from where you executed `xprop`.
assign [class="firefox"] $ws2
assign [class="Slack"] $ws1
assign [class="Journey"] $ws6
assign [class="youtube-music-desktop-app"] $ws10
assign [class="Google-chrome"] $ws3
assign [class="jetbrains-idea"] $ws7
assign [class="jetbrains-clion"] $ws7
assign [class="jetbrains-goland"] $ws7
#assign [class="Gnome-terminal"] $ws4
assign [class="DocumentNode"] $ws6
assign [class="Standard Notes"] $ws6
assign [class="KeePassXC"] $ws5
assign [class="Org.gnome.Nautilus"] $ws8
assign [class="Code"] $ws7

# Open specific applications in floating mode
for_window [title="alsamixer"] floating enable border pixel 1
for_window [class="Calamares"] floating enable border normal
for_window [class="Clipgrab"] floating enable
for_window [title="File Transfer*"] floating enable
for_window [class="Gnome-calculator"] floating enable border pixel 1
for_window [class="GParted"] floating enable border normal
for_window [title="i3_help"] floating enable sticky enable border normal
for_window [class="Lightdm-gtk-greeter-settings"] floating enable
for_window [class="Lxappearance"] floating enable sticky enable border normal
for_window [class="Manjaro-hello"] floating enable
for_window [class="Manjaro Settings Manager"] floating enable border normal
for_window [title="MuseScore: Play Panel"] floating enable
for_window [class="Nitrogen"] floating enable sticky enable border normal
for_window [class="Oblogout"] fullscreen enable
for_window [class="octopi"] floating enable
for_window [title="About Pale Moon"] floating enable
for_window [class="Pamac-manager"] floating enable
for_window [class="Pavucontrol"] floating enable
for_window [class="qt5ct"] floating enable sticky enable border normal
for_window [class="Qtconfig-qt4"] floating enable sticky enable border normal
for_window [class="Simple-scan"] floating enable border normal
for_window [class="(?i)System-config-printer.py"] floating enable border normal
for_window [class="Skype"] floating enable border normal
for_window [class="Thus"] floating enable border normal
for_window [class="Timeset-gui"] floating enable border normal
for_window [class="(?i)virtualbox"] floating enable border normal
for_window [class="Xfburn"] floating enable
for_window [class="Blueberry.py"] floating enable
for_window [class="Qalculate-gtk"] floating enable
for_window [class ="TelegramDesktop"] floating enable
for_window [class="gnome-screenshot"] floating enable
for_window [class="VirtualBox Machine"] floating disable
for_window [class="jetbrains-toolbox"] floating enable
#for_window [class="Gnome-terminal"] floating enable

# reload the configuration file
bindsym $mod+Shift+c reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r restart
# exit i3 (logs you out of your X session)
bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"

# resize window (you can also use the mouse for that)
mode "resize" {
        # These bindings trigger as soon as you enter the resize mode

        # Pressing left will shrink the window’s width.
        # Pressing right will grow the window’s width.
        # Pressing up will shrink the window’s height.
        # Pressing down will grow the window’s height.
        bindsym j resize shrink width 10 px or 10 ppt
        bindsym k resize grow height 10 px or 10 ppt
        bindsym l resize shrink height 10 px or 10 ppt
        bindsym ograve resize grow width 10 px or 10 ppt

        # same bindings, but for the arrow keys
        bindsym Left resize shrink width 10 px or 10 ppt
        bindsym Down resize grow height 10 px or 10 ppt
        bindsym Up resize shrink height 10 px or 10 ppt
        bindsym Right resize grow width 10 px or 10 ppt

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

bindsym $mod+r mode "resize"

# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)


# Widow Colours
client.focused $base0D $base0D $base00 $base01
client.focused_inactive $base02 $base02 $base03 $base01
client.unfocused $base01 $base01 $base03 $base01
client.urgent $base02 $base08 $base07 $base08

# Bar
bar {
    status_command i3status
    tray_output primary

    colors {
      separator $base03
      background $base01
      statusline $base05
      focused_workspace $base0C $base0D $base00
      active_workspace $base02 $base02 $base07
      inactive_workspace $base01 $base01 $base03
      urgent_workspace $base08 $base08 $base07
    }
}

# Execute Always commands
# wallpaper
exec_always feh --bg-scale $HOME/.config/i3/wallpapers/980479.jpg

while this is the i3status configuration file located at: $HOME/.config/i3status/config

general {
        output_format = "i3bar"
        colors = false
        markup = pango
        interval = 5
        color_good = '#2f343f'
        color_degraded = '#ebcb8b'
        color_bad = '#ba5e57'
}

order += "load"
order += "memory"
order += "cpu_temperature 0"
order += "disk /"
order += "disk /home"
order += "ethernet enp1s0"
order += "wireless wlp2s0"
order += "volume master"
order += "battery 1"
order += "tztime local"

load {
        format = "<span background='#000000'> %1min %5min %15min </span>"
}

cpu_temperature 0 {
        format = "<span background='#000000'>  %degrees °C </span>"
        path = "/sys/class/thermal/thermal_zone0/temp"
}

memory {
       format = "<span background='#000000'> %free %available (%used) / %total </span>"
       threshold_critical= "5%"
       format_degraded= "<span background='#ff0000'> Memory LOW: %free </span>"
}

disk "/" {
        format = "<span background='#000000'>  %free Free </span>"
}

disk "/home" {
        format = "<span background='#000000'>  %free Free </span>"
}

ethernet enp1s0 {
        format_up = "<span background='#000000'>  %ip </span>"
        format_down = "<span background='#000000'>  Disconnected </span>"
}

wireless wlp2s0 {
        format_up = "<span background='#000000'>  %essid </span>"
        format_down = "<span background='#000000'>  Disconnected </span>"
}

volume master {
        format = "<span background='#000000'>  %volume </span>"
        format_muted = "<span background='#000000'>  Muted </span>"
        device = "default"
        mixer = "Master"
        mixer_idx = 0
}

battery 1 {
    last_full_capacity = true
        format = "<span background='#000000'>  %status %percentage </span>"
        format_down = "No Battery"
        status_chr = "Charging"
        status_bat = "Battery"
        status_unk = "Unknown"
        status_full = "Charged"
        path = "/sys/class/power_supply/BAT0/uevent"
        low_threshold = 10
}

tztime local {
        format = "<span background='#000000'> %time </span>"
        format_time = " %a %-d %b %H:%M"
}


You'll only receive email when they publish something new.

More from Pietrangelo Masala