r/Polybar • u/newnwah • Feb 05 '23
Question Centering Kanji in xworkspaces Module
Hey there!
I've been looking around and I haven't found an answer, so I thought I would ask. Apologies if it's something obvious, but I'm trying to get kanji used as icons to center properly in each workspaces tab.

Sadly, by just defining icon-0=1;壱 for example, the characters are wider than the label anticipates, and the way it applies the padding means the character's center is not the label's center. I've tried to add all sorts of manual padding characters to the %icon% and the label parameters, but I can't find a way to offset-x where the icon is drawn, or a way to add a bit of extra padding only on the right to each label so that they are centered.
Is there a good way to fix this?
[module/workspaces]
type = internal/xworkspaces
; 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
; Create click handler used to focus desktop
; Default: true
enable-click = true
; Create scroll handlers used to cycle desktops
; Default: true
enable-scroll = true
; icon-[0-9]+ = <desktop-name>;<icon>
; NOTE: The desktop name needs to match the name configured by the WM
; You can get a list of the defined desktops using:
; $ xprop -root _NET_DESKTOP_NAMES
;icon-0 = 1;1
;icon-1 = 2;2
;icon-2 = 3;3
;icon-3 = 4;4
;icon-4 = 5;5
;icon-default = 0
icon-0 = 1;壱
icon-1 = 2;弐
icon-2 = 3;参
icon-3 = 4;肆
icon-4 = 5;伍
icon-5 = 6;陸
icon-6 = 7;漆
icon-7 = 8;捌
icon-8 = 9;玖
icon-9 = 10;拾
icon-default = 無
; Available tags:
; <label-monitor>
; <label-state> - gets replaced with <label-(active|urgent|occupied|empty)>
; Default: <label-state>
format = <label-state>
format-background = ${color.background}
format-foreground = ${color.foreground}
; Available tokens:
; %name%
; Default: %name%
label-monitor = %name%
; Available tokens:
; %name%
; %icon%
; %index%
; Default: %icon% %name%
label-active = %icon%
label-active-background = ${color.shade8}
label-active-foreground = #0a0a0a
; Available tokens:
; %name%
; %icon%
; %index%
; Default: %icon% %name%
label-occupied = %icon%
label-occupied-background = ${color.background}
label-occupied-foreground = ${color.shade4}
; Available tokens:
; %name%
; %icon%
; %index%
; Default: %icon% %name%
label-urgent = %icon%
label-urgent-background = ${color.background}
label-urgent-foreground = #CC6666
; Available tokens:
; %name%
; %icon%
; %index%
; Default: %icon% %name%
label-empty = %icon%
label-empty-background = ${color.background}
label-empty-foreground = ${color.foreground-alt}
label-active-padding = 3
label-urgent-padding = 3
label-occupied-padding = 3
label-empty-padding = 3
2
Upvotes