(gdb) break *0x972

Debugging, GNU± Linux and WebHosting and ... and ...

i3 named workspaces

Monday, September 19, 2016 - No comments

I recently improved my i3-wm configuration regarding the handling of workspaces. The idea is to have a quicker access to Firefox and Emacs, the main GUI tools I use for working. I initially added bindings to Urxvt terminal, but I happen to use it too much, so I cannot bind it to a particular workspace, they have to appear where ever I am :-)

Workspace names

set $wp_web 1: web
set $wp_edit 2: emacs
set $wp_work 3: work

set $wp_1 1: web # cannot use $variable here ...
set $wp_2 2: emacs
set $wp_3 3: work

assign [class="Firefox"] ? $wp_web
assign [class="^Emacs$"] ? $wp_edit

Switching workspace

# Win+1, Win+2 ...
bindcode Mod4+10 workspace $wp_1
bindcode Mod4+11 workspace $wp_2
bindcode Mod4+12 workspace $wp_3
bindcode Mod4+13 workspace 4
...

# quick Fn accesses
# F1 is Firefox, always focus to it during quick switches. 
# Same for F2 and emacs
bindsym F1 workspace $wp_1 ; [class="Firefox"] focus 
bindsym F2 workspace $wp_2 ; [class="Emacs"] focus
bindsym F3 workspace $wp_3
bindsym F4 workspace 4
# skip F5 (refresh in Firefox)
...

# quick back-and-forth with special key
bindsym Menu workspace back_and_forth # I would prefer a back-and-forth *on output*

# win-left/right
bindcode Mod4+86 workspace next
bindcode Mod4+82 workspace prev


# Mouse switch 1: left  2: middle  3: right
bindsym --whole-window Mod4+button1 workspace prev_on_output
bindsym --whole-window Mod4+button2 workspace back_and_forth
bindsym --whole-window Mod4+button3 workspace next_on_output

Moving workspaces and windows

# quick move
bindsym Shift+F1 move workspace $wp_1
bindsym Shift+F2 move workspace $wp_2
bindsym Shift+F3 move workspace $wp_3
bindsym Shift+F4 move workspace 4
...

# MOVE+Next/Prior keys to move the workspace
bindsym $Mod_move+Next move workspace next
bindsym $Mod_move+Prior move workspace prev

# Special key (UP/X) to move only window
bindcode $Mod_move+66 move window to output right;focus output right

# F12/F11 to move to hidden scratchpad / show it 
bindsym F12 move scratchpad
bindsym F11 scratchpad show

[Dev-tool configuration] i3 Window Manager

Tuesday, December 09, 2014 - No comments

Since a few years, I stopped using a traditional desktop manager like Gnome or KDE (maybe when Gnome switch to version 3?). I'm now addicted to my tiling window manager, i3. I3 manages only the windows on my screen, but not the desktop. Hence, when there's no window on my screen ... it's black! That could be improved, but most of the time, I have a window, so it doesn't matter. But no clickable icon, no clickable toolbar, just windows!

A tiling window manager (WM) gives the maximum room to each window, either by tabbing them, like in firefox, or by splitting (and sub-spliting) the screen horizontally or vertically:

Caught working hard

As there are no icons or clickable toolbar, everything is done with keyboard shortcuts. The learning curve, at the beginning, is a bit steep I admit! But one you get it, it's really nice to use!

Let's dive step-by-step into my configuration file:

Mod4 is 'Windows' key

Start applications

  • Mod4+Shift is the prefix to start applications. Mod4+Control is for alternative starts

    # Application shortcuts
    set $Mod_app Mod4+Shift
    set $Mod_app_alt Mod4+Control
    
  • Common tools:

    bindsym $Mod_app+f exec firefox
    bindsym $Mod_app+t exec thunderbird
    
    bindsym $Mod_app+m exec emacsclient -c # emacsclient needs an `emacs --daemon`
    bindsym $Mod_app_alt+m exec emacs # safe start, but takes longer
    
    # Start a terminal (urxvt client)
    bindsym $Mod_app+Return exec urxvtc # needs `urxvtd`
    bindsym $Mod_app_alt+Return exec urxvt # failsafe terminal
    
  • Force floating window (I guess these window don't respect all the protocols, so they are seen as primary windows, instead of floating boxes):

    for_window [class="Nautilus" instance="file_progress"] floating enable
    for_window [class="Xmessage"] floating enable
    for_window [title="Find"] floating enable
    
  • Helpers:

    bindsym Mod4+l exec i3lock -i /home/kevin/.i3/lock.png # locks the screen with a background image
    bindsym Mod4+F2 exec dmenu_run
    
    # Kill the current window
    bindsym $Mod_app+q kill # close the current 
    

See also dmenu_run, i3lock. I'll explain urxvtc and emacsclient in another post.

Window management

  • Window layout

    # Stacking / Tabbed / Default layout
    workspace_layout tabbed
    
    bindsym Mod4+s layout stacking
    bindsym Mod4+t layout tabbed
    bindsym Mod4+d layout default
    
  • Splitting windows

    default_orientation vertical
    # Split horizonally or vertically a window
    # *I can't help but consider than vertical split means that the window split should be vertical,
    # and the sub-windows side-by-side*, so I reversed h and v
    bindsym Mod4+h split vertical
    bindsym Mod4+v split horizontal
    
  • Moving windows

    set $Mod_move Mod4+Shift
    bindsym $Mod_move+Left move left
    bindsym $Mod_move+Right move right
    bindsym $Mod_move+Down move down
    bindsym $Mod_move+Up move up
    
    bindsym Mod4+f fullscreen
    bindsym Mod4+Mod1+f fullscreen global # on all screens
    
    # Toggle tiling/floating of the current window
    bindsym $Mod_move+space floating toggle
    
  • Changing the focus

    bindsym Mod4+Left focus left
    bindsym Mod4+Right focus right
    bindsym Mod4+Down focus down
    bindsym Mod4+Up focus up
    
  • Scratchpad (=invisible place)

    bindsym F12 move scratchpad
    bindsym F11 scratchpad show
    
  • Workspaces

    bindcode $Mod_move+10 move workspace 1 # touch 1
    bindcode $Mod_move+11 move workspace 2 # code for touch n = 9+n
    ...
    bindcode $Mod_move+86 move workspace next # touch +, found with `xev`
    bindcode $Mod_move+82 move workspace prev # touch -
    
  • Window resize

    # Window resize (although mouse is more convenient!)
    mode "resize" {
      bindsym Left resize grow left 10 px
      bindsym Shift+Left resize shrink left 10 px
    
      bindsym Down resize grow down 10 px
      bindsym Shift+Down resize shrink down 10 px
    
      bindsym Up resize grow up 10 px
      bindsym Shift+Up resize shrink up 10 px
    
      bindsym Right resize grow right 10 px
      bindsym Shift+Right resize shrink right 10 px
    
      #Enter to return to default
      bindsym Return mode "default"
    }
    

Misc.

  • Sound configuration

    set $Mod_sound Mod4+Mod1 #Win+Alt
    bindsym  $Mod_sound+m  exec amixer sset Master toggle
    bindcode $Mod_sound+82 exec amixer set Master 1%- # touch +
    bindcode $Mod_sound+86 exec amixer set Master 1%+ # touch -
    
    bindsym  XF86AudioMute exec amixer sset Master toggle # laptop multimedia keys
    bindsym  XF86AudioLowerVolume exec amixer set Master 1%-
    bindsym  XF86AudioRaiseVolume exec amixer set Master 1%+
    
    exec amixer sset Master mute # set to mute after boot sequence
    
  • Keyboard map (lang) configuration

    bindsym Mod4+Ctrl+f exec setxkbmap fr
    bindsym Mod4+Ctrl+u exec setxkbmap us
    
  • Borderless window or not

    hide_edge_borders both # by default, no side borders
    bindsym Mod4+p border normal
    bindsym Mod4+o border none # includes no window title
    
  • Restart and reload i3

    set $Mod_sys Mod4+Shift+Control
    bindsym $Mod_sys+e restart
    bindsym $Mod_sys+r reload
    
  • Home-made status bar (I'll put it online and explain it later)

    bindsym Mod4+Shift+w exec ~/.i3/i3status.py --kill --ws2
    bindsym Mod4+Ctrl+w exec ~/.i3/i3status.py --kill --ws1
    bar {
        position bottom
        mode hide
    }
    exec ~/.i3/i3status.py
    

Enjoy, i3 is a great tool, especially for development with multiple screens!