Module: i3

patrick96 edited this page Jul 23, 2018 · 26 revisions

This module uses the i3 ipc to display information about workspaces and active mode.

NOTE: Requires the project to be built with i3 support; Check for +i3 in polybar -vvv

Accessible workspace cycling

You are able to define fallback click handlers for the whole bar window. Using those you could cycle your workspaces by scrolling anywhere on the bar (except existing areas setup for the same button). You should probably disable scrolling for the module (enable-scroll = false) if you are using this method.

The messages i3wm-ws{prev,next} are handled internally by the running i3 module and they will send the appropriate commands using the i3 ipc. You can replace it by any other command if you want a different behavior

[bar/mybar]
scroll-up = i3wm-wsnext
scroll-down = i3wm-wsprev
;scroll-up = i3-msg workspace next_on_output
;scroll-down = i3-msg workspace prev_on_output

Basic settings

[module/i3]
type = internal/i3

; Only show workspaces defined on the same output as the bar
;
; Useful if you want to show monitor specific workspaces
; on different bars
;
; Default: false
pin-workspaces = true

; This will split the workspace name on ':'
; Default: false
strip-wsnumbers = true

; Sort the workspaces by index instead of the default
; sorting that groups the workspaces by output
; Default: false
index-sort = true

; Create click handler used to focus workspace
; Default: true
enable-click = false

; Create scroll handlers used to cycle workspaces
; Default: true
enable-scroll = false

; Wrap around when reaching the first/last workspace
; Default: true
wrapping-scroll = false

; Set the scroll cycle direction 
; Default: true
reverse-scroll = false

; Use fuzzy (partial) matching on labels when assigning 
; icons to workspaces
; Example: code;♚ will apply the icon to all workspaces 
; containing 'code' in the label
; Default: false
fuzzy-match = true

Additional formatting

; ws-icon-[0-9]+ = label;icon
; NOTE: The label needs to match the name of the i3 workspace
ws-icon-0 = 1;
ws-icon-1 = 2;
ws-icon-2 = 3;
ws-icon-3 = 4;
ws-icon-4 = 5;
ws-icon-default = ♟
; NOTE: You cannot skip icons, e.g. to get a ws-icon-6
; you must also define a ws-icon-5.

; Available tags:
;   <label-state> (default) - gets replaced with <label-(focused|unfocused|visible|urgent)>
;   <label-mode> (default)
format = <label-state> <label-mode>

; Available tokens:
;   %mode%
; Default: %mode%
label-mode = %mode%
label-mode-padding = 2
label-mode-background = #e60053

; Available tokens:
;   %name%
;   %icon%
;   %index%
;   %output%
; Default: %icon%  %name%
label-focused = %index%
label-focused-foreground = #ffffff
label-focused-background = #3f3f3f
label-focused-underline = #fba922
label-focused-padding = 4

; Available tokens:
;   %name%
;   %icon%
;   %index%
;   %output%
; Default: %icon%  %name%
label-unfocused = %index%
label-unfocused-padding = 4

; Available tokens:
;   %name%
;   %icon%
;   %index%
;   %output%
; Default: %icon%  %name%
label-visible = %index%
label-visible-underline = #555555
label-visible-padding = 4

; Available tokens:
;   %name%
;   %icon%
;   %index%
;   %output%
; Default: %icon%  %name%
label-urgent = %index%
label-urgent-foreground = #000000
label-urgent-background = #bd2c40
label-urgent-padding = 4

; Separator in between workspaces
label-separator = |
label-separator-padding = 2
label-separator-foreground = #ffb52a

Generate ws-icon list

#!/bin/bash
counter=0
i3-msg -t get_workspaces | tr ',' '\n' | sed -nr 's/"name":"([^"]+)"/\1/p' | while read -r name; do
  printf 'ws-icon-%i = "%s;<insert-icon-here>"\n' $((counter++)) $name
done
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.