I3 Workspaces Module


#1

I found an i3 workspaces module I really liked at /r/unixporn so I modded it to suit.

Polybar Module

[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 = false

; 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 = true

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

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

; 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


; ws-icon-[0-9]+ = label;icon
; NOTE: The label needs to match the name of the i3 workspace
ws-icon-0 = term;
ws-icon-1 = ffox;
ws-icon-2 = email;
ws-icon-3 = file;
ws-icon-4 = music;
ws-icon-5 = gimp;
ws-icon-6 = edit;
ws-icon-7 = torr;
;ws-icon-default = 

; 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 = 5
label-mode-background = ${colors.background}

; Available tokens:
;   %name%
;   %icon%
;   %index%
;   %output%
; Default: %icon%  %name%
label-focused = %icon%  %name%
label-focused-foreground = ${colors.foreground}
label-focused-background = ${colors.background}
label-focused-underline = #b13f47
label-focused-padding = 5

; Available tokens:
;   %name%
;   %icon%
;   %index%
; Default: %icon%  %name%
label-unfocused =  %icon%  %name%
label-unfocused-foreground = ${colors.foreground}
label-unfocused-background = ${colors.background}
label-unfocused-padding = 5

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

; Available tokens:
;   %name%
;   %icon%
;   %index%
; Default: %icon%  %name%
label-urgent =  %icon%  %name%
label-urgent-foreground = ${colors.foreground-alt}
label-urgent-background = ${colors.background}
label-urgent-padding = 5

i3 config for workspaces:

set $WS1 "1:term"
set $WS2 "2:ffox"
set $WS3 "3:email"
set $WS4 "4:file"
set $WS5 "5:music"
set $WS6 "6:gimp"
set $WS7 "7:edit"
set $WS8 "8:torr"

For this to work, the workspaces have to be named the same in both the module and i3 config.

I got the original config from this amazing post.

What it looks like:


#2

Hey there Dobbie,

tried this config as the workspaces on i3 never worked for me even just after installing i3-gaps clean without touching anyhting. It looked like this:
ws

Now I took your code and pasted it 1:1 into my polybar modules.conf and i3 config but none of the workspaces showed up, now there is showing up nothing at all anymore.

Any idea what the problem is? Sorry, I am not very familiar with changing the looks of a menubar/wm just yet…

Thanks a lot, cheers


#3

You haven’t set your workspace names correctly.

Copy exactly what I originally posted. Reboot and let me know the outcome.


#4

Thanks for your reply.

As I said before, I tried your exact config and it didn not work which is why I tried to mess with it in the first place. I tried again, still no workspaces showing up.
Configs now are:

; ws-icon-[0-9]+ = label;icon
; NOTE: The label needs to match the name of the i3 workspace
ws-icon-0 = term;
ws-icon-1 = ffox;
ws-icon-2 = email;
ws-icon-3 = file;
ws-icon-4 = music;
ws-icon-5 = gimp;
ws-icon-6 = edit;
ws-icon-7 = torr;
;ws-icon-default =

set $WS1 “1:term”
set $WS2 “2:ffox”
set $WS3 “3:email”
set $WS4 “4:file”
set $WS5 “5:music”
set $WS6 “6:gimp”
set $WS7 “7:edit”
set $WS8 “8:torr”

Also, any idea why the vanilla ws indicator did not work in the first place?


#5

No idea why the vanilla indicator didn’t work. A reboot seems to be the best way for any changes to the workspace module to show.


#6

I think I got it.
In the i3 config file, $Mon1 and $Mon2 were by standard defined as HDMI1 and HDMI2. As I am using a dual screen setup with 1x HDMI flatscreen and the internal notebook screen, I had to change Mon1 to eDP1 and it is now at least showing something where the workspaces should be.
Will have to tweak further, but I will let you know how it all turned out when I am done. Thanks anyways @Dobbie03!

edit:
Yep, it is working now. Looking good like that:
ws

Again, your exact code did not work for me. I assume it might be something like not having defined the ${} variables, maybe? Anyway, I do now have a mix of your example and the modified vanilla version that works just fine so I am happy for now :slight_smile:


#7

Good work, I’m glad it is all sorted!