Files
literate-dotfiles/i3.org

9.8 KiB

I3 Configuration

# i3 config file (v4)

Mod Key

Set mod key (Mod1=<Alt>, Mod4=<Super>)

set $mod Mod4
set $alt Mod1

Border Style

default_border pixel 2
default_floating_border pixel 2
for_window [class="^.*"] border pixel 2

Hide borders

hide_edge_borders none

Font for window titles

font pango:Hack Nerd Font Mono 11

Colors Variables

set_from_resource $bg         color0  #000000
set_from_resource $darkred    color1  #000000
set_from_resource $darkgreen  color2  #000000
set_from_resource $darkyellow color3  #000000
set_from_resource $darkblue   color4  #000000
set_from_resource $darkpurple color5  #000000
set_from_resource $darkaqua   color6  #000000
set_from_resource $darkgray   color7  #000000
set_from_resource $gray       color8  #000000
set_from_resource $red        color9  #000000
set_from_resource $green      color10 #000000
set_from_resource $yellow     color11 #000000
set_from_resource $blue       color12 #000000
set_from_resource $purple     color13 #000000
set_from_resource $aqua       color14 #000000
set_from_resource $fg         color15 #000000

Theme colors

# class                 border  backgr. text    indic.   child_border
client.focused          $darkaqua $darkaqua $fg  $bg
client.focused_inactive $bg    $bg    $fg     $bg
client.unfocused        $bg    $bg    $fg     $bg
client.urgent           $bg    $bg    $fg     $bg

client.background       $bg

Various Config

Layout mode for new containers

workspace_layout default

Focus Configuration

focus_follows_mouse no
focus_on_window_activation none

Settings for i3-gaps

gaps inner 10
gaps outer 1
smart_gaps off

Workspace names

To display names or symbols instead of plain workspace numbers you can use something like: set $ws1 1:mail and set $ws2 2:.

set $ws1 1
set $ws2 2
set $ws3 3
set $ws4 4
set $ws5 5
set $ws6 6
set $ws7 7
set $ws8 8
workspace 1 output DP-3-2
workspace 3 output DP-3-2
workspace 5 output DP-3-2
workspace 7 output DP-3-2
workspace 9 output DP-3-2

workspace 2 output DP-3-1
workspace 4 output DP-3-1
workspace 6 output DP-3-1
workspace 8 output DP-3-1

Use Mouse+$mod to drag floating windows

floating_modifier $mod

Back and Forth

workspace_auto_back_and_forth yes

Application Specific

Open applications on specific workspaces

for_window [title="^Fig"] move to workspace $ws6
for_window [title="^HG_Peer"] move to workspace $ws6
for_window [title="^Fig"] layout tabbed
# assign[class="^RDP"] 7 # Remote
for_window [class="^RDP"] move to workspace $ws7
for_window [class="^RDP"] layout tabbed

Open specific applications in floating mode

for_window [class="floating"] floating enable
for_window [title="File Transfer*"] floating enable
for_window [class="GParted"] floating enable border normal
for_window [class="Lxappearance"] floating enable sticky enable border normal
for_window [class="pwvucontrol"] floating enable
for_window [class="Arandr"] floating enable
for_window [class="Simple-scan"] floating enable border normal
for_window [class="(?i)System-config-printer.py"] floating enable border normal
for_window [title="^Documentation -"] floating enable border normal
for_window [class="Yad"] floating enable
for_window [title="Bluetooth Devices"] floating enable
for_window [class="Floating"] floating enable, resize set 800 600, move position 1100 460
for_window [class="mpv"] floating enable # Size/Position is defined in mpv.conf
for_window [class="Nsxiv"] floating enable, resize set 800 600, move position center
for_window [class="Cropgui"] floating enable, resize set 800 600, move position center
for_window [title="khal"] floating enable, resize set 600 600, move position center
for_window [class="jellyfin-tui"] floating enable, resize set 1200 800, move position center
for_window [title="ncmpcpp"] floating enable, resize set 800 400, move position center
for_window [title="stig"] floating enable, resize set 800 400, move position center
for_window [title="Sensors"] floating enable, resize set 800 400, move position center
for_window [title="TexText"] floating enable, resize set 800 400, move position center
for_window [title="nmtui"] floating enable, resize set 800 600, move position center
for_window [title="Xournal"] floating enable, resize set 1100 750, move position center
for_window [title="esrf-phonebook"] floating enable, resize set 1400 400, move position center
for_window [title="^zoom$" class="[zoom]*"] floating enable
for_window [title="F3D"] floating enable, resize set 800 600, move position center
# Simulink
for_window [title="Simulink Library Browser"] floating enable
for_window [title="^Block Parameters:.*"] floating enable, move position center

Others

no_focus [title="zoom_linux_float_message_reminder"]

Scratchpad

Move the currently focused window to the scratchpad

bindsym $mod+Shift+BackSpace move scratchpad

Show the next scratchpad window or hide the focused scratchpad window. If there are multiple scratchpad windows, this command cycles through them.

bindsym $mod+BackSpace scratchpad show

I3 key bindings

Kill Window

# close and kill
bindsym $mod+q kill

Set the window State

# Set the window to full-screen
bindsym $mod+f fullscreen toggle

# Set the window to floating
bindsym $mod+s floating toggle

# Alternate between the tiled and normal layout
bindsym $mod+t layout toggle tabbed split

# Change focus between tiling / floating windows
bindsym $mod+c focus mode_toggle

# Sticky window
bindsym $mod+y sticky toggle

focus/swap

# Focus/swap the node in the given direction
bindsym $mod+h exec --no-startup-id i3-msg focus left && i3-focus-sync
bindsym $mod+j exec --no-startup-id i3-msg focus down && i3-focus-sync
bindsym $mod+k exec --no-startup-id i3-msg focus up && i3-focus-sync
bindsym $mod+l exec --no-startup-id i3-msg focus right && i3-focus-sync

bindsym $mod+Shift+h move left
bindsym $mod+Shift+j move down
bindsym $mod+Shift+k move up
bindsym $mod+Shift+l move right
# Focus the next/previous desktop in the current monitor
bindsym $mod+p workspace prev
bindsym $mod+n workspace next

# Focus the last Desktop
bindsym $mod+b exec --no-startup-id i3-msg workspace back_and_forth && i3-focus-sync

# Focus to the given desktop
bindsym $mod+1 workspace 1
bindsym $mod+2 workspace 2
bindsym $mod+3 workspace 3
bindsym $mod+4 workspace 4
bindsym $mod+5 workspace 5
bindsym $mod+6 workspace 6
bindsym $mod+7 workspace 7
bindsym $mod+8 workspace 8
bindsym $mod+9 workspace 9

bindsym $mod+ctrl+1 move container to workspace 1
bindsym $mod+ctrl+2 move container to workspace 2
bindsym $mod+ctrl+3 move container to workspace 3
bindsym $mod+ctrl+4 move container to workspace 4
bindsym $mod+ctrl+5 move container to workspace 5
bindsym $mod+ctrl+6 move container to workspace 6
bindsym $mod+ctrl+7 move container to workspace 7
bindsym $mod+ctrl+8 move container to workspace 8
bindsym $mod+ctrl+9 move container to workspace 9

bindsym $mod+Shift+1 move container to workspace 1; workspace 1
bindsym $mod+Shift+2 move container to workspace 2; workspace 2
bindsym $mod+Shift+3 move container to workspace 3; workspace 3
bindsym $mod+Shift+4 move container to workspace 4; workspace 4
bindsym $mod+Shift+5 move container to workspace 5; workspace 5
bindsym $mod+Shift+6 move container to workspace 6; workspace 6
bindsym $mod+Shift+7 move container to workspace 7; workspace 7
bindsym $mod+Shift+8 move container to workspace 8; workspace 8
bindsym $mod+Shift+9 move container to workspace 9; workspace 9

Preselect

Preselect the direction

# Set Horizontal Layout
bindsym $mod+ctrl+h split h
bindsym $mod+ctrl+l split h

# Set Vertical Layout
bindsym $mod+ctrl+j split v
bindsym $mod+ctrl+k split v

Resize

Expand/Shrink a window

# Horizontal Shrink
bindsym $mod+$alt+h resize shrink width 10 px or 10 ppt
# Vertical Grow
bindsym $mod+$alt+j resize grow height 10 px or 10 ppt
# Vertical Shrink
bindsym $mod+$alt+k resize shrink height 10 px or 10 ppt
# Horizontal Grow
bindsym $mod+$alt+l resize grow width 10 px or 10 ppt

Fix focus for WM_TAKE_FOCUS applications

Some applications (e.g. OnlyOffice, Electron apps) use the WM_TAKE_FOCUS protocol and fail to release X11 keyboard focus when i3 moves focus elsewhere. This keybinding forces X11 focus to the window i3 currently considers focused.

win=$(i3-msg -t get_tree | python3 -c "
import json, sys
def find_focused(node):
    if node.get('focused') and node.get('window'):
        return node['window']
    for child in node.get('nodes', []) + node.get('floating_nodes', []):
        r = find_focused(child)
        if r is not None:
            return r
    return None
w = find_focused(json.load(sys.stdin))
if w is not None: print(w)
" 2>/dev/null)
[ -n "$win" ] && xdotool windowfocus --sync "$win" 2>/dev/null

Run Polybar and SXHKD

# exec --no-startup-id sxhkd -m 1 -c ~/.config/sxhkd/sxhkdrc.i3
exec --no-startup-id sxhkd -m 1
exec --no-startup-id polybar top >>/tmp/polybar.log 2>&1 &