i3wm Configuration Files
Table of Contents
About
This is my personal i3wm configuration. The actual code itself is inside this one org-mode file that can be tangled from inside Emacs with the command org-babel-tangle-file
. I'm using Gnu Stow to create symlinks from the files tangled in this org file into my home directory since not all the files in this repository needs to be symlinked1.
i3wm
The i3-wm package that I used is from the default repository in archlinux.
variables
Mostly these variables are set to avoid repetion.
- mod key
Mod4
is theSuper
key, orWin
key for the rest of the world.Mod1
isAlt
2. You don't have to set this variable, but by using variable, we can change the mod key without having to change each individual lines of keybindings.set $mod Mod4
- notify
I used dunst as a desktop notification, though there's many other packages that can replace it. I prefer dunst because it's easier to configure.
set $notify exec notify-send -t 1000
- refresh i3status
The preferred status bar for i3, I like the simplicity of i3status.
set $refresh_i3status killall -SIGUSR1 i3status
- navigation keys
I use vim keys obviously.
set $up k set $down j set $left h set $right l
- workspaces
I tried to have a uniformed workspaces across all my window manager configurations. Some
set $ws1 "1: Term" set $ws2 "2: Code" set $ws3 "3: Web" set $ws4 "4: Mail" set $ws5 "5: File" set $ws6 "6: Office" set $ws7 "7: Games" set $ws8 "8: Remote" set $ws9 "9: Torrent" set $ws10 "10: Chat"
Set
=workspace_back_and_forth
workspace_auto_back_and_forth yes
- applications
set $terminal xterm set $browser firefox set $mail thunderbird set $guiemacs emacsclient -c -a emacs set $tuiemacs emacsclient -t -a emacs set $file thunar
- Xresouces
#### https://build.i3wm.org/docs/userguide.html#xresources set_from_resource $background_i3wm background #000000 set_from_resource $foreground_i3wm foreground #000000 set_from_resource $color00_i3wm color0 #000000 set_from_resource $color01_i3wm color1 #000000 set_from_resource $color02_i3wm color2 #000000 set_from_resource $color03_i3wm color3 #000000 set_from_resource $color04_i3wm color4 #000000 set_from_resource $color05_i3wm color5 #000000 set_from_resource $color06_i3wm color6 #000000 set_from_resource $color07_i3wm color7 #000000 set_from_resource $color08_i3wm color8 #000000 set_from_resource $color09_i3wm color9 #000000 set_from_resource $color10_i3wm color10 #000000 set_from_resource $color11_i3wm color11 #000000 set_from_resource $color12_i3wm color12 #000000 set_from_resource $color13_i3wm color13 #000000 set_from_resource $color14_i3wm color14 #000000 set_from_resource $color15_i3wm color15 #000000
- Colors
# Theme colors # class border backgr. text indic. child_border # My colors client.background $background_i3wm client.focused $foreground_i3wm $background_i3wm $foreground_i3wm $background_i3wm $background_i3wm client.unfocused $foreground_i3wm $background_i3wm $foreground_i3wm $background_i3wm $background_i3wm client.focused_inactive $foreground_i3wm $background_i3wm $foreground_i3wm $background_i3wm $background_i3wm client.urgent $foreground_i3wm $background_i3wm $foreground_i3wm $background_i3wm $background_i3wm client.placeholder $foreground_i3wm $background_i3wm $foreground_i3wm $background_i3wm $background_i3wm
- font
# font font pango:JetBrainsMonoNL Nerd Font Mono 10
- floating modifier
floating_modifier $mod
bar
bar { status_command i3status position bottom workspace_buttons yes mode dock colors { statusline $color04_i3wm background $background_i3wm separator $color03_i3wm # BORDER BACKGROUND TEXT focused_workspace $color03_i3wm $color00_i3wm $color02_i3wm inactive_workspace $color00_i3wm $color00_i3wm $color02_i3wm active_workspace $color00_i3wm $color00_i3wm $color01_i3wm urgent_workspace $color01_i3wm $background_i3wm $color00_i3wm binding_mode $color03_i3wm $background_i3wm $color00_i3wm } }
Also set keybinding for toggling bar.
bindsym $mod+Control+m bar mode toggle
application autostart
# exec --no-startup-id ~/.local/bin/monitor-setup exec --no-startup-id systemctl --user import-environment DISPLAY XDG_CURRENT_DESKTOP QT_QPA_PLATFORMTHEME QT_XCB_GL_INTEGRATION exec --no-startup-id dbus-update-activation-environment --systemd --all exec --no-startup-id dbus-launch --exit-with-session gnome-keyring-daemon --components=pkcs11,secrets,ssh -r -d exec --no-startup-id /usr/lib/polkit-kde-authentication-agent-1 & exec --no-startup-id xsetroot -cursor_name left_ptr exec --no-startup-id xset r rate 300 30 exec --no-startup-id xrdb -merge ~/.Xresources #exec --no-startup-id dex --autostart --environment i3 exec --no-startup-id dbus-launch --exit-with-session picom -b --config "${XDG_CONFIG_HOME}"/picom/picom.conf & exec --no-startup-id dbus-launch --exit-with-session udiskie -t & exec --no-startup-id dbus-launch dunst -conf ~/.config/dunst/dunstrc & exec --no-startup-id /usr/lib/geoclue-2.0/demos/agent & exec --no-startup-id dbus-launch --exit-with-session /usr/lib/kdeconnectd & exec --no-startup-id dbus-launch --exit-with-session nm-applet --indicator & exec --no-startup-id dbus-launch --exit-with-session xsettingsd & exec --no-startup-id dbus-launch blueman-applet & exec --no-startup-id dbus-launch --exit-with-session unclutter & exec --no-startup-id dbus-launch volumeicon & exec --no-startup-id dbus-launch --exit-with-session greenclip daemon>/dev/null & exec --no-startup-id $file --daemon & exec --no-startup-id ~/.local/bin/transfer-sleep-lock-i3lock-fancy & exec --no-startup-id systemctl --user start redshift-gtk exec --no-startup-id wal -R exec --no-startup-id ~/.fehbg #exec --no-startup-id feh --no-fehbg --bg-fill '/home/mkncorp.com/kristian.alexander/.local/share/wallpapers/manga/Sora-no-Otoshimono/angels_sora_no_otoshimono_ikaros_anime_anime_g_by_kardolen65_d6wp5ec.jpg' # exec --no-startup-id xclipboard
window rule
for_window [class=".*"] border pixel 0 # for_window [class="(?i)xclipboard"] , move scratchpad for_window [instance="(?i)pavucontrol"] floating enable for_window [window_role="pop-up"] floating enable for_window [instance="(?i)engrampa"] floating enable for_window [window_role="GtkFileChooserDialog"] floating enable for_window [title="(?i)alsamixer"] floating enable for_window [class="(?i)qtconfig-qt4"] floating enable for_window [title="(?i)nmtui"] floating enable for_window [window_role="buddy_list"] floating enable, resize set 360 680 for_window [window_role="conversation"] floating enable, resize set 480 680 for_window [class="(?i)blueman.*"] floating enable, resize set 512 256 for_window [class="evolution-alarm-notify"] floating enable for_window [class="Evolution-alarm-notify"] floating enable for_window [class="(?i)kooha"] floating enable for_window [class="^org.kde.polkit-kde-authentication-agent-1"] floating enable for_window [class="thunderbird" title="status"] floating enable for_window [class="thunderbird" title="(.*)Reminders"] floating enable for_window [class="thunderbird" title="Write.*"] floating enable resize set 680 680 for_window [class="thunderbird" title="Send.*"] floating enable for_window [class="Msgcompose.*"] floating enable resize set 680 680 for_window [class="QtPass"] floating enable for_window [class="(?i)zoom"] floating enable for_window [class="(?i)file-roller"] floating enable for_window [class="(?i)ncmpcpp"] floating enable for_window [class="(?i)khal"] floating enable for_window [class="(?i)htop"] floating enable for_window [class="(?i)nmtui"] floating enable for_window [class="(?i)vim"] floating enable for_window [class="(?i)org.kde.kdeconnect.app"] floating enable for_window [title="(?i)File Operation Progress"] floating enable for_window [class="(?i)showmethekey-gtk"] floating enable for_window [class="(?i)screenkey"] floating enable for_window [class="(?i)bitwarden"] floating enable for_window [class="(?i)authy.*"] floating enable for_window [class="(?i)transmission.*"] floating enable for_window [class="(?i)anydesk.*"] floating enable for_window [class="(?i)lxappearance"] floating enable for_window [class="(?i)steam.*"] floating enable
workspace assignment
- workspace 1
assign [class="XTerm"] $ws1 assign [class="URxvt"] $ws1 assign [class="Gnome-terminal"] $ws1 assign [class="Termite"] $ws1
- workspace 2
assign [class="Emacs"] $ws2 assign [class="Leafpad"] $ws2 assign [class="L3afpad"] $ws2 assign [class="Gedit"] $ws2 assign [class="code-oss"] $ws2
- workspace 3
assign [class="qutebrowser"] $ws3 assign [class="firefox"] $ws3 assign [class="google-chrome"] $ws3 assign [class="Nyxt"] $ws3 assign [class="pidgin"] $ws7
- workspace 4
assign [class="Evolution"] $ws4 assign [class="thunderbird"] $ws4
- workspace 5
assign [class="Rhythmbox"] $ws5 assign [class="vlc"] $ws5 assign [class="mpv"] $ws5 assign [class="Cheese"] $ws5 assign [class="Spotify"] $ws5 assign [class="Picard"] $ws5
- workspace 6
assign [class="org.remmina.remmina"] $ws6 assign [class="Virt-manager"] $ws6 assign [class="Vncviewer"] $ws6
- workspace 7
assign [class="Steam"] $ws7 assign [title="Steam"] $ws7
- workspace 8
assign [title="Libreoffice"] $ws8 assign [title="com-sonicwall-NetExtender"] $ws8 assign [title="Bitwarden"] $ws8 assign [title="zoom"] $ws8
- workspace 9
assign [class="Gucharmap"] $ws9 assign [class="org.gnome.Characters"] $ws9 assign [class="Thunar"] $ws9
- workspace 0
assign [class="winbox.exe"] $ws10
Keybindings
- media keys
bindsym XF86AudioRaiseVolume exec --no-startup-id ~/.local/bin/dunst-volume -i 1 && $refresh_i3status bindsym XF86AudioLowerVolume exec --no-startup-id ~/.local/bin/dunst-volume -d 1 && $refresh_i3status bindsym XF86AudioMute exec --no-startup-id ~/.local/bin/dunst-volume -t && $refresh_i3status bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status bindsym XF86AudioPlay exec playerctl play-pause bindsym XF86AudioNext exec playerctl next bindsym XF86AudioPrev exec playerctl previous bindsym XF86MonBrightnessUp exec --no-startup-id ~/.local/bin/dunst-backlight +1% bindsym XF86MonBrightnessDown exec --no-startup-id ~/.local/bin/dunst-backlight 1%- bindsym Print exec flameshot gui
For keyboard with no media keys:
bindsym $mod+F9 exec --no-startup-id ~/.local/bin/dunst-volume -i 1 && $refresh_i3status bindsym $mod+F8 exec --no-startup-id ~/.local/bin/dunst-volume -d 1 && $refresh_i3status bindsym $mod+F7 exec --no-startup-id ~/.local/bin/dunst-volume -t && $refresh_i3status bindsym $mod+F11 exec playerctl play-pause bindsym $mod+F12 exec playerctl next bindsym $mod+F10 exec playerctl previous bindsym $mod+Shift+F3 exec --no-startup-id brightnessctl set +1% bindsym $mod+Shift+F2 exec --no-startup-id brightnessctl set 1%-
- browser
bindsym XF86MyComputer exec $browser bindsym $mod+Mod1+f exec $browser
- mail
bindsym XF86Mail exec $mail bindsym $mod+Mod1+t exec $mail
- music
bindsym $mod+Mod1+m exec $terminal --class ncmpcpp -e ncmpcpp
- htop
bindsym $mod+Mod1+h exec $terminal --class htop -e htop
- nmtui
bindsym $mod+Mod1+w exec $terminal --class nmtui -e nmtui
- khal
bindsym $mod+Mod1+k exec $terminal --class khal -e khal interactive
- vim
bindsym $mod+Mod1+v exec $terminal --class vim -e vim
- dired
bindsym $mod+Mod1+e exec emacsclient -c -a emacs -e '(dired (getenv "HOME"))'
- rofi-pass
Rofi front end for pass. It stores passwords using git and encrypted with GnuPG. It also has an OTP extensions.
bindsym $mod+Mod1+p exec rofi-pass
- rofi-calc
bindsym $mod+Mod1+c exec rofi -show calc -modi calc -no-show-match -no-sort -theme calculator
- rofi-rbw
Similar to rofi-pass, but for bitwarden.
bindsym $mod+Mod1+b exec rofi-rbw
- text editor
bindsym $mod+Mod1+n exec $guiemacs bindsym $mod+Control+n exec $terminal -e $tuiemacs
- file manager
bindsym $mod+e exec $file
- terminal
bindsym $mod+Return exec $terminal
- terminal + screen
bindsym $mod+Shift+Return exec $terminal -e screen -m
- kill focused window
bindsym $mod+Shift+F4 kill bindsym Mod1+F4 kill
- rofi-menu
bindsym $mod+d exec --no-startup-id rofi -show drun -theme i3-apps
- rofi-greenclip
bindsym $mod+c exec --no-startup-id rofi -theme i3-apps -modi "clipboard:greenclip print" -show clipboard
- rofi window menu
bindsym $mod+shift+w exec rofi -theme i3-apps -show windowcd bindsym $mod+w exec rofi -theme i3-apps -show window
- tesseract
bindsym $mod+shift+t exec ~/.local/bin/ocr
- screenkey
bindsym $mod+Mod1+s exec screenkey
- window management
- change focus
bindsym $mod+$left focus left bindsym $mod+$down focus down bindsym $mod+$up focus up bindsym $mod+$right focus right
Alternatively, with arrow 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+$left move left bindsym $mod+Shift+$down move down bindsym $mod+Shift+$up move up bindsym $mod+Shift+$right move right
Also, with arrow 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
horizontally
bindsym $mod+Control+h split h; exec $notify "Horizontal split"
vertically
bindsym $mod+Control+v split v exec $notify "Vertical split"
- fullscreen toggle
bindsym $mod+f fullscreen toggle; exec $notify "Fullscreen toggle"
- container layout
stacked
bindsym $mod+Control+s layout stacking; exec $notify "Stacking layout"
tabbed
bindsym $mod+Control+w layout tabbed; exec $notify "Tabbed layout"
split
bindsym $mod+Control+e layout toggle split; exec $notify "Split toggle"
- toggle tiling / floating
bindsym $mod+Shift+space floating toggle; exec $notify "Floating toggle"
- change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle; exec $notify "Window focus toggle"
- focus parent container
bindsym $mod+Control+a focus parent; exec $notify "Focus parentcontainer"
- focus child container
bindsym $mod+Control+d focus child; exec $notify "Focus child container"
- move to scratchpad
Move the current focused window into the scratchpad
bindsym $mod+Shift+minus move scratchpad; exec $notify "Moved to scratchpad"
- show 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+minus scratchpad show; exec $notify "Show scratchpad" bindsym $mod+Shift+c [class="(?i)xclipboard"] scratchpad show
- change focus
- workspace management
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
- switch to workspace prev / next
bindsym $mod+bracketleft workspace prev bindsym $mod+bracketright workspace next
- move focused containerto 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
- move using bracket keys
bindsym Control+Mod1+bracketleft move to workspace previous bindsym Control+Mod1+bracketright move to workspace next
- back and forth
bindsym $mod+Tab workspace back_and_forth bindsym $mod+Shift+Tab move container to workspace back_and_forth
- switch output focus
bindsym $mod+Control+1 focus output primary bindsym $mod+Control+2 focus output right
- moving to output
bindsym $mod+Control+Shift+1 move workspace to output primary bindsym $mod+Control+Shift+2 move workspace to output right
- switch to workspace prev / next
- Reload configuration
bindsym $mod+Shift+F11 reload
- Hot restart
bindsym $mod+Control+r restart
- exit i3
bindsym $mod+q exec ~/.local/bin/rofi-i3-logout
- picom transparency
bindsym $mod+F3 exec picom-trans -c +5 bindsym $mod+F2 exec picom-trans -c -5
- dunst
bindsym $mod+Mod1+grave exec dunstctl history-pop bindsym $mod+Shift+grave exec dunstctl context bindsym $mod+Control+grave exec dunstctl close bindsym $mod+grave exec dunstctl action
- modes
- resize
# 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 $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 # 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"
- resize
i3status
general
general { colors = true interval = 5 output_format = i3bar }
order
order += "ipv6" order += "wireless _first_" order += "ethernet _first_" order += "battery 0" order += "memory" order += "tztime local"
wireless
wireless _first_ { format_up = ": (%quality at %essid, %bitrate / %frequency) %ip" format_down = ": down" }
ethernet
ethernet _first_ { format_up = ": %ip (%speed)" format_down = "" }
battery
battery 0 { format = "%status %percentage %remaining" format_down = "" status_chr = "" status_bat = "" status_unk = "" last_full_capacity = true }
memory
memory { format = " %used" threshold_degraded = "1G" format_degraded = " < %available" }
time
tztime local { format = " %Y-%m-%d %H:%M:%S" }
Scripts
ocr
This utilize the tesseract package. The script simply select an area in the desktop with maim, pipe it into tesseract, which also pipes it into xclip.
maim -u -s -b 5 -l -c 0.3,0.4,0.6,0.4 -d 0.1 | tesseract -l eng - - | xclip -selection clipboard notify-send -i ebook-reader "OCR" "Saved to clipboard"
Rofi
- i3-nord theme
I separate the main nord theme here so I can make changes to it without 'disturbing' other window manager settings.
/* -*-css-*- */ /** * Nordic rofi theme * Adapted by undiabler <undiabler@gmail.com> * * Nord Color palette imported from https://www.nordtheme.com/ * */ * { nord0: #2e3440; nord1: #3b4252; nord2: #434c5e; nord3: #4c566a; nord4: #d8dee9; nord5: #e5e9f0; nord6: #eceff4; nord7: #8fbcbb; nord8: #88c0d0; nord9: #81a1c1; nord10: #5e81ac; nord11: #bf616a; nord12: #d08770; nord13: #ebcb8b; nord14: #a3be8c; nord15: #b48ead; foreground: @nord9; backlight: #ccffeedd; background-color: transparent; highlight: underline bold #eceff4; transparent: rgba(46,52,64,0); } window { location: center; anchor: center; transparency: "screenshot"; padding: 10px; border: 0px; border-radius: 6px; background-color: @transparent; spacing: 0; children: [mainbox]; orientation: horizontal; } mainbox { spacing: 0; children: [ inputbar, message, listview ]; } message { color: @nord0; padding: 5; border-color: @foreground; border: 0px 2px 2px 2px; background-color: @nord7; } inputbar { color: @nord6; padding: 11px; background-color: @nord1; border: 1px; border-radius: 6px 6px 0px 0px; border-color: @nord10; } entry, prompt, case-indicator { text-font: inherit; text-color:inherit; } prompt { margin: 0px 1em 0em 0em ; } listview { padding: 8px; border-radius: 0px 0px 6px 6px; border-color: @nord10; border: 0px 1px 1px 1px; background-color: rgba(46,52,64,0.9); dynamic: false; } element { padding: 3px; vertical-align: 0.5; border-radius: 4px; background-color: transparent; color: @foreground; text-color: rgb(216, 222, 233); } element selected.normal { background-color: @nord7; text-color: #2e3440; } element-text, element-icon { background-color: inherit; text-color: inherit; } button { padding: 6px; color: @foreground; horizontal-align: 0.5; border: 2px 0px 2px 2px; border-radius: 4px 0px 0px 4px; border-color: @foreground; } button selected normal { border: 2px 0px 2px 2px; border-color: @foreground; }
- i3-apps theme
/* -*-css -*- */ @theme "i3-nord" window { location: southwest; anchor: center; width: 40%; x-offset: 20%; y-offset: -10%; /* padding-right: 25px; */ } listview { columns: 2; lines: 6; } /* inputbar { */ /* children: [textbox-prompt]; */ /* } */ /* textbox-prompt { */ /* str: "Apps"; */ /* text-color: inherit; */ /* } */
- i3-logout theme
/* -*-css -*- */ @theme "i3-nord" window { location: northeast; anchor: center; transparency: "screenshot"; width: 10%; padding: 10px; border: 0px; border-radius: 6px; x-offset: -5%; y-offset: 10%; spacing: 0; children: [mainbox]; } listview { columns: 1; lines: 4; }
i3-logout
question=$(echo " lock| logout| reboot| shutdown" | rofi -sep "|" \ -dmenu -i -p 'System: ' "" \ -hide-scrollbar \ -eh 1 \ -color-enabled true \ -theme "i3-logout") case $question in *lock) i3lock-fancy ;; *logout) i3-msg exit ;; *reboot) if [[ $(command -v systemctl) ]]; then systemctl reboot else shutdown -r now fi ;; *shutdown) if [[ $(command -v systemctl) ]]; then systemctl poweroff else poweroff fi ;; *) exit 0 # do nothing on wrong response ;; esac
transfer screen lock
A locker script for i3lock-fancy and xss-lock. Requires xidlehook
# get the primary display export PRIMARY_DISPLAY="$(xrandr | awk '/ primary/{print $1}')" # Run xidlehook xidlehook \ `# Don't lock when there's a fullscreen application` \ --not-when-fullscreen \ `# Don't lock when there's audio playing` \ --not-when-audio \ `# Dim the screen after 60 seconds, undim if user becomes active` \ --timer 60 \ 'xrandr --output "$PRIMARY_DISPLAY" --brightness .1' \ 'xrandr --output "$PRIMARY_DISPLAY" --brightness 1' \ `# Undim & lock after 10 more seconds` \ --timer 10 \ 'xrandr --output "$PRIMARY_DISPLAY" --brightness 1; i3lock-fancy -d ' \ '' \ `# Finally, suspend an hour after it locks` \ --timer 3600 \ 'systemctl suspend' \ ''