Toon’s i3 configuration


i3 configuration

Based from the auto-generated file created by i3-config-wizard(1).

Please see https://i3wm.org/docs/userguide.html for a complete reference!

Monitor configuration

At startup, only enable my built-in laptop screen.

exec xrandr --output eDP-1 --auto --output DP-1 --off --output DP-2 --off

Having correct HiDPI requires ~/.Xresources, see https://dougie.io/linux/hidpi-retina-i3wm/

export GDK_SCALE=2
export GDK_DPI_SCALE=0.5
export QT_AUTO_SCREEN_SCALE_FACTOR=1

Button configuration

i3 modifier

Make the Windows/Cmd/Whatever key the i3 modifier.

set $mod Mod4

Make CAPS lock a Ctrl

Make CAPS lock an additional Ctrl key.

exec setxkbmap -option ctrl:nocaps

Appearance

Border

I don’t want no borders.

default_border normal 3
hide_edge_borders both

Font

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:FuraCode Nerd Font Mono 8

Default

Make tabbed the default layout:

workspace_layout tabbed

Mouse

Drag windows

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

floating_modifier $mod

Natural scrolling

Enable natural scrolling for the trackpad.

exec xinput set-prop "SynPS/2 Synaptics TouchPad" "libinput Natural Scrolling Enabled" 1

Enable tapping

Enable click on tap.

exec xinput set-prop "SynPS/2 Synaptics TouchPad" "libinput Tapping Enabled" 1

Some bindings

Terminal

Start a terminal.

bindsym $mod+Return exec i3-sensible-terminal

Kill

Kill focused window.

bindsym $mod+Shift+q kill

Launcher

Start dmenu (a program launcher).

bindsym $mod+d exec dmenu_run

There also is the (new) i3-dmenu-desktop which only displays applications shipping a .desktop file. It is a wrapper around dmenu, so you need that installed.

bindsym $mod+d exec --no-startup-id i3-dmenu-desktop

Change focus

Use vim-like keys to change focus to a different window.

bindsym $mod+h focus left
bindsym $mod+j focus down
bindsym $mod+k focus up
bindsym $mod+l 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

Moving windows

Move focused window, with the same keys, combined with Shift.

bindsym $mod+Shift+h move left
bindsym $mod+Shift+j move down
bindsym $mod+Shift+k move up
bindsym $mod+Shift+l 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

Splitting containers

Split in horizontal orientation.

bindsym $mod+n split h

Split in vertical orientation.

bindsym $mod+v split v

Fullscreen

Enter fullscreen mode for the focused container

bindsym $mod+f fullscreen toggle

Container layout

Change container layout:

  • Stacked
  • Tabbed
  • Toggle Split
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split

Floating

Toggle between tiling & floating.

bindsym $mod+Shift+space floating toggle

Change focus between tiling / floating windows.

bindsym $mod+space focus mode_toggle

Change focus

Focus the parent container.

bindsym $mod+a focus parent

Focus the child container.

bindsym $mod+d focus child

Workspaces

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"
set $ws2 "2"
set $ws3 "3"
set $ws4 "4"
set $ws5 "5"
set $ws6 "6"
set $ws7 "7"
set $ws8 "8"
set $ws9 "9"
set $ws0 "0"

Switching workspace

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 $ws0

Moving containers

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 $ws0

Move workspaces between monitors

Source: https://unix.stackexchange.com/a/397270/9358

bindsym $mod+Ctrl+greater move workspace to output right
bindsym $mod+Ctrl+less move workspace to output left

Choose monitor setup

I have 2 external monitors and using a mode to enable/disable them.

set $mode_monitors Monitor setup: (0) laptop only, (1) one external, (2) two external
mode "$mode_monitors" {
  bindsym 0 exec --no-startup-id "xrandr --output DP-1 --off --output DP-2 --off", mode "default"
  bindsym 1 exec --no-startup-id "xrandr --output eDP-1 --auto --output DP-1 --auto --left-of eDP-1 --output DP-2 --off", mode "default"
  bindsym 2 exec --no-startup-id "xrandr --output eDP-1 --auto --output DP-1 --auto --left-of eDP-1 --output DP-2 --auto --left-of DP-1", mode "default"

  # back to normal: Enter or Escape
  bindsym Return mode "default"
  bindsym Escape mode "default"
}
bindsym XF86Display mode "$mode_monitors"

Controlling i3 itself

Reload

Reload the configuration file.

bindsym $mod+Shift+c reload

Restart

Restart i3 inplace. This preserves your layout/session, can be used to upgrade i3.

bindsym $mod+Shift+r restart

Exit

Exit i3. It 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'"

Resizing

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 semicolon 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"

Shutdown

A mode to select the shutdown/reboot/etc.

From i3wm faq.

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 i3lock, mode "default"
  bindsym e exec --no-startup-id i3-msg exit, mode "default"
  bindsym s exec --no-startup-id "i3lock; systemctl suspend", mode "default"
  bindsym h exec --no-startup-id "i3lock; systemctl hibernate", mode "default"
  bindsym r exec --no-startup-id systemctl reboot, mode "default"
  bindsym Shift+s exec --no-startup-id systemctl poweroff, mode "default"

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

Brightness

From https://askubuntu.com/a/823691/850746 using light.

bindsym XF86MonBrightnessUp exec light -A 2
bindsym XF86MonBrightnessDown exec light -U 2

Media keys

I used to use pactl.

bindsym XF86AudioRaiseVolume exec --no-startup-id "pactl info | grep 'Default Sink' | cut -d: -f2 | xargs -I{} pactl set-sink-volume {} +5%"
bindsym XF86AudioLowerVolume exec --no-startup-id "pactl info | grep 'Default Sink' | cut -d: -f2 | xargs -I{} pactl set-sink-volume {} -5%"
bindsym XF86AudioMute exec --no-startup-id "pactl info | grep 'Default Sink' | cut -d: -f2 | xargs -I{} pactl set-sink-mute {} toggle"

Until I learned there is [[https://unix.stackexchange.com/a/439487/9358][a better way]].

bindsym XF86AudioMute exec amixer sset 'Master' toggle
bindsym XF86AudioLowerVolume exec amixer -n sset 'Master' 5%-
bindsym XF86AudioRaiseVolume exec amixer -n sset 'Master' 5%+

But then this better way turned out to be less reliable and also does not allow me to go over 100%, which is something desired.

Screenshots

Create screenshots.

About the use of --release, see https://www.reddit.com/r/i3wm/wiki/faq/screenshot_binding

Print
Save screenshot of selected area to file.
Shift + Print
Save screenshot of selected area to clipboard.
Ctrl + Print
Save screenshot of whole screen to file.
bindsym --release Print exec --no-startup-id "gnome-screenshot -a"
#bindsym --release Shift+Print exec --no-startup-id "gnome-screenshot -ac"
bindsym --release Shift+Print exec --no-startup-id "import png:- | xclip -selection clipboard -t image/png"
bindsym --release Ctrl+Print exec --no-startup-id "gnome-screenshot"

Status bar

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

bar {
  status_command i3status
}

Applets

Network manager

Start network manager applet.

exec --no-startup-id nm-applet

Dropbox

Start dropbox daemon.

exec --no-startup-id exec ~/.dropbox-dist/dropboxd

Window assignment

Assign some windows to a workspace. Just like I want them.

assign [class="Slack"] → $ws1
#assign [class="-terminal$"] → $ws2
assign [class="^Emacs"] → $ws3
assign [class="^Firefox$"] → $ws4
assign [class="^Firefox Developer Edition$"] → $ws5

Floating windows

Some windows aren’t properly handled as floating by default.

“zoom”
This window is a little popup shown when someone has become the host of the meeting
for_window [title="^zoom$"] floating enable

Workspace assignment

Also each workspace has its preferred screen. By specifying multiple outputs, the first one available will be used.

workspace $ws1 output primary
workspace $ws2 output DP-1 primary
workspace $ws3 output DP-1 primary
workspace $ws4 output DP-1 primary
workspace $ws5 output DP-2 DP-1 primary