Show Us Your Polybar

Just use the exec internal module type and for the command something like

dkcmd status num=1 | grep '^L' | sed 's/^L//'

This will just print the active workspace layout, you can rip the array from the bar.sh script and put the above command in a script and do a lookup in the array like in the bar.sh script, or use fancy glyphs in the array.

# define layouts array
...
layout=$(dkcmd status num=1 | grep '^L' | sed 's/^L//')
layout="${layouts[$layout]}"
echo "${layout:-???}"  # ??? If current layout is unknown

EDIT: fix typo in echo line

1 Like

Thanks

That’s what I was trying this morning.

1 Like

Got something working -

although, I’m sure the script sits firmly in the hack category.

polybar module:

[module/layouts]
type = custom/script
;exec-if = uptime
exec = /home/doug/.config/polybar/dklayout.sh
;format-prefix = "  "
format-prefix =
interval = 1
format-prefix-foreground = ${colors.dimgray}
format-prefix-background = ${colors.background}
label-background = ${colors.background}
format-background = ${colors.background}
format-foreground = ${colors.dimgray}

dklayout.sh

#!/bin/bash

# define layouts array

# mimic dwm style layout symbols
typeset -A layouts=(
[tile]="[]="
[mono]="[M]"
[none]="><>"
[grid]="###"
[spiral]="(@)"
[dwindle]="[\\]"
[tstack]="F^F"
)

layout=$(dkcmd status num=1 | grep '^L' | sed 's/^L//')
layout="${layouts[$layout]}"
# echo "${$layout:-???}"  # ??? If current layout is unknown # error line 18: ${$layout:-???}: bad substitution

echo $layout
1 Like

Ahh yea very nice, mb on the layout error (phone code), it should be ${layout:-???} not ${$layout:-???}

1 Like

That fixes it.

1 Like

Nice work guys, I added some icons to mine to reflect how my dwm setup is.

#!/bin/bash

# define layouts array

# mimic dwm style layout symbols
typeset -A layouts=(
[tile]="󰙀"
[mono]="󰃚"
[none]="󰕯"
[grid]="󰕰"
[spiral]="󰕬"
[dwindle]="󰕴"
[tstack]="󱒉")

layout=$(dkcmd status num=1 | grep '^L' | sed 's/^L//')
layout="${layouts[$layout]}"
# echo "${$layout:-???}"  # ??? If current layout is unknown # error line 18: ${$layout:-???}: bad substitution

echo $layout

These icons will require Material Design font to be installed and to be listed in your fonts in the Polybar config.

3 Likes

@cog

modules.conf

[module/xdesktops]
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 = false
reverse-scroll = false
fuzzy-match = false

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

; Available tokens:
;   %name%
; Default: %name%
label-monitor = %name%

; Available tokens:
;   %name%
;   %icon%
;   %index%
; Default: %icon%  %name%
label-active = "%{T5}%name%%{T-}"
label-active-foreground = #6699CC
label-active-padding = 1

; Available tokens:
;   %name%
;   %icon%
;   %index%
; Default: %icon%  %name%
label-occupied = "%{T5}%name%%{T-}"
label-occupied-foreground = #bcbcdc
label-occupied-background = #202020
label-occupied-padding = 1


; Available tokens:
;   %name%
;   %icon%
;   %index%
; Default: %icon%  %name%
label-urgent = "%{T5}%name%%{T-}"
label-urgent-foreground = ${colors.foreground}
label-urgent-background = #dd2727
label-urgent-padding = 1

; Available tokens:
;   %name%
;   %icon%
;   %index%
; Default: %icon%  %name%
label-empty = "%{T5}%name%%{T-}"
label-empty-foreground = #444444
label-empty-background = #202020
label-empty-padding = 1


[module/date]
type = internal/date
interval = 60
date = %a
time = "%d-%m-%y %R "
format-padding = 0
format-background = #202020
format-foreground = ${colors.foreground}
format-prefix =""
format-prefix-foreground = #dcdcfa
label = %date% %time%


[module/cpu]
type = internal/cpu
format = <label>
format-background = #202020
format-prefix = 
format-prefix-foreground = #dcdcfa
format-prefix-background = #202020
label = %percentage%%
label-padding = 0
format-prefix-padding = 0


[module/pulseaudio]
type = internal/pulseaudio

; Sink to be used, if it exists (find using `pacmd list-sinks`, name field)
; If not, uses default sink
;sink = alsa_output.pci-0000_12_00.3.analog-stereo

; Use PA_VOLUME_UI_MAX (~153%) if true, or PA_VOLUME_NORM (100%) if false
; Default: true
use-ui-max = true

; Interval for volume increase/decrease (in percent points)
; Default: 5
interval = 5

; Available tags:
;   <label-volume> (default)
;   <ramp-volume>
;   <bar-volume>
label-volume = %percentage%%

format-volume = <ramp-volume><label-volume>
format-volume-background = #202020
label-volume-padding = 0
format-muted-prefix = ""
format-muted-prefix-foreground = #dcdcfa
format-muted-background = #202020
label-muted = "muted"
label-muted-foreground = ${colors.foreground}

ramp-volume-0 = 
ramp-volume-1 = 
ramp-volume-2 = 
ramp-volume-3 = 
ramp-volume-4 = 

ramp-volume-foreground = #dcdcfa


[module/eth]
type = internal/network
interface = enp3s0
interval = 3.0

format-connected-prefix = 
format-connected-prefix-foreground = #dcdcfa
format-connected-background = #202020
format-connected-prefix-background = #202020
label-connected = %ifname%

format-disconnected =
format-disconnected-prefix = 
format-disconnected-prefix-foreground = #96c6f8
format-disconnected-background = #202020


[module/wlan]
type = internal/network
interface = wlan0
interval = 300
format-connected = <ramp-signal><label-connected>%
format-connected-background = #202020
format-connected-padding = 0
label-connected = %signal%
format-disconnected = <label-disconnected>
format-disconnected-prefix = 
format-disconnected-prefix-foreground = #dcdcfa
format-disconnected-background = #202020
label-disconnected = x

; Only applies if <ramp-signal> is used
ramp-signal-0 = 
ramp-signal-1 = 
ramp-signal-2 = 
ramp-signal-3 = 
ramp-signal-4 = 
ramp-signal-foreground = #475166


[module/internet]
type = custom/script
exec = ~/.local/bin/statusbar/internet
interval = 10
format-foreground = ${colors.foreground}
format-background = #202020


[module/battery]
type = internal/battery
battery = BAT0
adapter = ADP1
full-at = 100

format-charging = <animation-charging><label-charging>
format-charging-background = #202020
format-charging-foreground = ${colors.foreground}
format-charging-padding = 0
label-charging = %percentage%%

format-discharging = <ramp-capacity><label-discharging>
format-discharging-background = #202020
format-discharging-foreground = ${colors.foreground}
format-discharging-padding = 0
label-discharging = %percentage%%

format-full-background = #202020
format-full-foreground = ${colors.foreground}
format-full-padding = 0
format-full-prefix = 
format-full-prefix-foreground = #dcdcfa
label-full = 100%

; Only applies if <ramp-capacity> is used
ramp-capacity-0 = 
ramp-capacity-1 = 
ramp-capacity-2 = 
ramp-capacity-3 = 
ramp-capacity-4 = 
ramp-capacity-5 = 
ramp-capacity-6 = 
ramp-capacity-7 = 
ramp-capacity-8 = 
ramp-capacity-9 = 
ramp-capacity-foreground = #dcdcfa

; Only applies if <animation-charging> is used
animation-charging-0 = 
animation-charging-1 = 
animation-charging-2 = 
animation-charging-3 = 
animation-charging-foreground = #dcdcfa
; Framerate in milliseconds
animation-charging-framerate = 750


[module/updates-arch-combined]
type = custom/script
exec = ~/.config/polybar/scripts/updates-arch-combined.sh
interval = 600
label = %output%
format-background = #202020
format-padding = 0
format-prefix = ""
format-prefix-foreground = #dcdcfa


[module/xwindow]
type = internal/xwindow
label = " %title:0:80:...% "
format-foreground = #6699CC


[module/ssd]
type = custom/script
exec = ~/.config/polybar/scripts/disk
interval = 600
label = %output%
label-padding = 
format-background = #202020
format-prefix = ""
format-prefix-foreground = #dcdcfa


[module/mem]
type = custom/script
exec = ~/.config/polybar/scripts/mem.sh
interval = 3
label = %output%
label-padding = 
format-background = #202020
format-prefix = ""
format-prefix-foreground = #dcdcfa


[module/weather]
type = custom/script
exec = ~/.local/bin/statusbar/weather
interval = 18000
format-foreground = ${colors.foreground}
format-background = #202020


[module/layout]
type = custom/script
exec = ~/.config/polybar/scripts/yaxws
interval = 1
format-prefix =
format-foreground = ${colors.foreground}
format-background = #202020


[module/nettraf]
type = custom/script
exec = ~/.local/bin/statusbar/nettraf
interval = 1
format-background = #202020


[module/sep]
type = custom/text
content = " "
;content-foreground = #5bb955
content-background = #202020
content-padding = 0

master.conf

;=====================================================
;     Colors & Settings
;=====================================================

[colors]
background = #202020
foreground = #dcdcfa

;colors for icons #475166 #928374 #667c9d

[settings]
throttle-output = 5
throttle-output-for = 10
throttle-input-for = 30
compositing-background = source
compositing-foreground = source
compositing-overline = source
compositing-underline = source
compositing-border = source
screenchange-reload = true
format-foreground = ${colors.foreground}
format-background = ${colors.background}

;=====================================================
;    Master Bar
;=====================================================

[bar/master]
width = 100%
height = 15
border-size = 0
border-top-size = 0
border-bottom-size = 0
radius = 0
bottom = false
line-size = 3

font-0 = "Siji:size=8;2"
font-1 = monospace:style=Regular:antialias=true:size=8;2
font-2 = FontAwesome5Free:style=Solid:size=7;2
font-3 = FontAwesome5Free:style=Regular:size=7;2
font-4 = FontAwesome5Brands:style=Regular:size=7;2

offset-x = 0
offset-y = 0
fixed-center = true
background = ${colors.background}
foreground = ${colors.foreground}
module-margin = 0
padding-right = 0
padding-left = 0
tray-position = right

; shows which modules have click actions
;cursor-click = pointer

enable-ipc = true

config

;=====================================================
; The system tray and other default values for bars
; inheriting from master are enabled in master.conf
;
; modules.conf contains all the modules that can be
; added to a bar (NOTE: some will require configuration)

[section/base]
include-file = /home/rml/.config/polybar/master.conf
include-file = /home/rml/.config/polybar/modules.conf


;=====================================================
; Yaxwm Bars

[bar/yax-bar]
inherit = bar/master

; Use $ xrandr -q | grep " connected" | cut -d ' ' -f1
monitor =

modules-left   = xdesktops sep layout xwindow
modules-center =
modules-right  = eth sep wlan sep cpu sep mem sep ssd sep updates-arch-combined sep pulseaudio sep battery sep date
6 Likes

@rml thanks buddy

1 Like

Top @rml

For those who updated polybar to the latest version, the battery module might not be working because format-low doesn’t exist. If the module is not working just add it and some color to it, like format-low = #ee5555 and it will start working again. Maybe someone forgot to document this change to the new release.

2 Likes

not on AL atm, but this is my polybar

trying out some blurred panels

4 Likes

Nice and colourful.

Wow, thats nice @PackRat.

1 Like

My Polybar has had a heap of work on it today, it is a dirty hacked together Powerline style, behold:

2021-10-11-18-29-44-scrot.png

Configs here if anyone is interested.

6 Likes

It looks cool. Nice venture from your typical setup.

1 Like

Thanks, I’ll probably keep this one.

dk window manager, dual monitor, separate polybar on each monitor:

workspace settings from dkrc, 5 workspaces assigned to each monitor:

	# workspace settings
	# ------------------------

	# initialize 10 workspaces (1-10)
	dkcmd set numws=10

	# default workspace '_' values used when allocating new workspaces
	# can be applied to all existing workspaces when passed 'apply' after ws=_
	dkcmd set ws=_ apply layout=tile master=1 stack=3 msplit=0.55 ssplit=0.5 gap=0

	dkcmd set ws=6 layout=tile pad left=4 right=4 top=4 bottom=4 gap=4
	dkcmd set ws=7 layout=dwindle pad left=4 right=4 top=4 bottom=4 gap=4
	dkcmd set ws=8 layout=spiral pad left=4 right=4 top=4 bottom=4 gap=4
	dkcmd set ws=9 layout=float
	# use grid layout, padding, and gaps on workspace 10
	dkcmd set ws=10 layout=grid pad left=4 right=4 top=4 bottom=4 gap width=12

	# use static workspaces (not default)
	# dkcmd set static_ws=false
	dkcmd set static_ws=true

	# change workspace names
	dkcmd set \
		ws=1  name="1" \
		ws=2  name="2" \
		ws=3  name="3" \
		ws=4  name="4" \
		ws=5  name="5" \
		ws=6  name="6" \
		ws=7  name="7" \
		ws=8  name="8" \
		ws=9  name="9" \
		ws=10 name="10"

	# assign workspaces to monitors (requires static_ws=true)
	mon1='HDMI1'
	mon2='VGA1'
	dkcmd set \
	 	ws=1  mon=$mon1 \
	 	ws=2  mon=$mon1 \
	 	ws=3  mon=$mon1 \
	 	ws=4  mon=$mon1 \
	 	ws=5  mon=$mon1 \
	 	ws=6  mon=$mon2 \
	 	ws=7  mon=$mon2 \
	 	ws=8  mon=$mon2 \
	 	ws=9  mon=$mon2 \
	 	ws=10 mon=$mon2

relevant parts of polybar:

configuration for two bars, each bar is given an unique name and inherits a different “master” file:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; dk
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

[bar/dk-bar]
inherit = bar/master

modules-left = appmenu dk-workspaces dklayouts
modules-center = chronos
modules-right = coregraph ramgraph lan-network

; Position of the system tray window
; If empty or undefined, tray support will be disabled
; NOTE: A center aligned tray will cover center aligned modules
;
; Available positions:
;   left
;   center
;   right
;   none
;tray-position = right

; If true, the bar will not shift its
; contents when the tray changes
;tray-detached = false

; Tray icon max size
;tray-maxsize = 16

; Background color for the tray container 
; ARGB color (e.g. #f00, #ff992a, #ddff1023)
; By default the tray container will use the bar
; background color.
;tray-background = ${root.background}

; Tray offset defined as pixel value (e.g. 35) or percentage (e.g. 50%)
tray-offset-x = 0
;tray-offset-y = 0

; Pad the sides of each tray icon
;tray-padding = 0

; Scale factor for tray clients
;tray-scale = 1.0

[bar/dkvga-bar]
inherit = bar/master-02

modules-left = appmenu dk-workspaces dklayouts
modules-center = chronos
modules-right = filesystem

; Position of the system tray window
; If empty or undefined, tray support will be disabled
; NOTE: A center aligned tray will cover center aligned modules
;
; Available positions:
;   left
;   center
;   right
;   none
;tray-position = right

; If true, the bar will not shift its
; contents when the tray changes
;tray-detached = false

; Tray icon max size
;tray-maxsize = 16

; Background color for the tray container 
; ARGB color (e.g. #f00, #ff992a, #ddff1023)
; By default the tray container will use the bar
; background color.
;tray-background = ${root.background}

; Tray offset defined as pixel value (e.g. 35) or percentage (e.g. 50%)
tray-offset-x = 0
;tray-offset-y = 0

; Pad the sides of each tray icon
;tray-padding = 0

; Scale factor for tray clients
;tray-scale = 1.0

the only difference in the master files is the monitor to use:

[bar/master]
; Use either of the following command to list available outputs:
; If unspecified, the application will pick the first one it finds.
; $ polybar -m | cut -d ':' -f 1
; $ xrandr -q | grep " connected" | cut -d ' ' -f1
monitor = HDMI1

; Use the specified monitor as a fallback if the main one is not found.
monitor-fallback = HDMI1

; Require the monitor to be in connected state
; XRandR sometimes report my monitor as being disconnected (when in use)
monitor-strict = false
[bar/master-02]
; Use either of the following command to list available outputs:
; If unspecified, the application will pick the first one it finds.
; $ polybar -m | cut -d ':' -f 1
; $ xrandr -q | grep " connected" | cut -d ' ' -f1
monitor = VGA1

; Use the specified monitor as a fallback if the main one is not found.
monitor-fallback = VGA1

; Require the monitor to be in connected state
; XRandR sometimes report my monitor as being disconnected (when in use)
monitor-strict = false

similar to bspwm, a separate workspace module for dk:

[module/dk-workspaces]
type = internal/xworkspaces
pin-workspaces = true
enable-click = true
enable-scroll = false
format-padding = 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 =
format = <label-state>
label-active = " %name% "
label-active-foreground = ${colors.white}
label-active-background = ${colors.darkgray}
label-active-underline = ${colors.darkgray}

label-occupied = " %name% "
label-occupied-foreground = ${colors.gray}
lable-occupied-background = ${colors.background}
label-occupied-underline = ${colors.background}

label-urgent = " %name% "
label-urgent-foreground = ${colors.white}
label-urgent-background = ${colors.urgent}
label-urgent-underline = ${colors.urgent}

label-empty = " %name% "
label-empty-foreground = ${colors.dimgray}
label-empty-background = ${colors.background}
;label-empty-underline = ${colors.background}

Everything else is pretty much stock polybar modules.

6 Likes

Awesome.

1 Like

Checking out some new features with polybar 3.6 - warning thresholds (final values will be set closer to the defaults):

cpu, memory, battery modules have warning thresholds now - polybar git page

7 Likes

An ordinary polybar -kinda “heavy”- with a few additions:

Polywins, a taskbar for polybar
openweathermap-fullfeatured modified by me to show the wind as well. Converts m/s to beaufort and shows the corresponding image.

Openbox’s right click menu instead of launcher and a simple calendar when i click the time.

10 Likes