Polybar

This literate configuration is available online on my GitHub Pages. Please, if you appreciate my work, consider making a donation.

Table of Contents

Laptop Bar

This is my laptop’s Polybar. It is the primary status bar, and started by default by the window manager.

Setup

This first block registers the bar “laptop” with Polybar, and assigns it to the display eDP1.

;    ____        __      __
;   / __ \____  / /_  __/ /_  ____ ______
;  / /_/ / __ \/ / / / / __ \/ __ `/ ___/
; / ____/ /_/ / / /_/ / /_/ / /_/ / /
;/_/    \____/_/\__, /_.___/\__,_/_/
;              /____/

[bar/laptop]
bottom = true
width = 100%
height = 33
radius = 0
fixed-center = false
enable-ipc = true

monitor = eDP1
monitor-exact = true
monitor-strict = true

Appearance

Here are some general appearance settings, like colors, padding, and font. Remember, in the hex colors for Polybar’s config, the first two digits are for the alpha channel. Like this: #aarrggbb . So a color beginning with “#ff” would render with 100% opacity. Hex colors with only 6 digits will be rendered fully opaque, and the colors will be interpreted like #rrggbb.

background = ${xrdb:polybar.color0}
foreground = ${xrdb:polybar.color1}
line-size = 3
line-color = #f00
padding-left = 0
padding-right = 0

font-0 = SpaceMono Nerd Font:size=16:antialias=true

Here we define the modules on the left and right sides of the laptop’s Polybar. Some system tray properties are also set. Modules appear in the order they are listed on these next two lines. Notice the expressions that look like ${xrdb:polybar.colorx}, these will retrieve color strings from Xresources, so ricing is a little easier.

modules-left = bspwm
modules-right = mpd pulse memory cpu battery date

tray-position = right
tray-padding = 2
tray-maxsize = 33
tray-background = ${xrdb:polybar.color2}

wm-restack = bspwm

scroll-up = #bspwm.next
scroll-down = #bspwm.prev

Monitor Bar

The monitor’s Polybar has three modules the laptop’s (my primary) bar doesn’t: The network module, the window title, and the HDD module.

Setup

This block registers the monitor’s Polybar and assigns it to the display HDMI2.

[bar/monitor]
bottom = true
width = 100%
height = 32
radius = 0
fixed-center = false
enable-ipc = true

monitor = HDMI2
monitor-exact = true
monitor-strict = true

Appearance

The font size should be a little bigger for the monitor’s bar.

background = ${xrdb:polybar.color0}
foreground = ${xrdb:polybar.color1}

tray-position = right
tray-padding = 2
tray-maxsize = 40

font-0 = SpaceMono Nerd Font:size=17:antialias=true

line-size = 2
line-color = #f00
border-size = 0
padding-left = 0
padding-right = 0

Here are the modules.

scroll-up = #bspwm.next
scroll-down = #bspwm.prev

modules-left = bspwm
modules-right = title hdd network battery date

wm-restack = bspwm

Modules

HDD

Show remaining disk space.

[module/hdd]
type = internal/fs

mount-0 = /
interval = 1
fixed-values = true
spacing = 2

format-mounted = <label-mounted>
label-mounted = "  %free% "
format-mounted-foreground = #ffee7369
#format-mounted-underline = ${xrdb:polybar.color4}
format-mounted-background = #6acd5349

Title

Shows the title of the currently focused window.

[module/title]
type = internal/xwindow
format = <label>
format-foreground = #efedc4c4
format-padding = 3

label = %title%
label-maxlen = 58

label-empty = bspwm
label-empty-foreground = #bfddb4b4

Network

Shows upload and download traffic. Uncomment those lines to have underlines.

[module/network]
type = internal/network
interface = wlp0s20f3
interval = 1.0

format = <ramp-signal> <label-connected>
format-connected = <ramp-signal> <label-connected>
format-disconnected = "not connected"
format-disconnected-foreground = #ccedc2c2
#format-disconnected-underline = ${xrdb:polybar.color14}

label-connected = "%downspeed:5%  %upspeed:5%  "
label-connected-foreground = #ef83d288
format-connected-foreground = #ef83d288
#format-connected-underline = ${xrdb:polybar.color13}
format-connected-background = #7a539f58

ramp-signal-0 = " "

Bspwm

The Bspwm workspace listing, including focused colors, occupied colors, and empty colors. The roman numerals in the icon strings are taken from bspwmrc.

[module/bspwm]
type = internal/bspwm

ws-icon-0 = "I;"
ws-icon-1 = "II;爵"
ws-icon-2 = "III;"
ws-icon-4 = "V;"
ws-icon-5 = "VI;"
ws-icon-3 = "IV;"
ws-icon-6 = "VII;"
ws-icon-7 = "VIII;"
ws-icon-8 = "IX;"

label-focused = %icon%

label-focused-background = #9acd5349
label-focused-foreground = #ffefcdcd
#label-focused-underline = ${xrdb:polybar.color6}
label-focused-padding = 1

label-occupied = %icon%
label-occupied-padding = 1
label-occupied-foreground = #ef5b9ad1
label-occupied-background = #9a4b8ac0
#label-occupied-underline = ${xrdb:polybar.color8}

label-urgent = %icon%!
label-urgent-background = #ffff0000
label-urgent-padding = 1

label-empty = %icon%
label-empty-background = #7addb474
label-empty-foreground = #efeec484
label-empty-padding = 1

scroll-up = bspwm-desknext
scroll-down = bspwm-deskprev

MPD

MPD music player.

[module/mpd]
type = internal/mpd
format-online = <label-song> <icon-prev> <toggle> <icon-next>
format-online-foreground = #efedc1c1

host = 127.0.0.2
port = 6600

label-active-font = 2

icon-play = 
icon-pause = 
icon-stop = +
icon-prev = 
icon-next = 

label-song-maxlen = 56
label-song-ellipsis = true

Pulseaudio

Pulseaudio volume.

[module/pulse]
type = internal/pulseaudio

sink = alsa_output.pci-0000_00_1f.3.analog-stereo

interval = 2

format-volume = <ramp-volume> <label-volume>
format-muted = "<label-muted> "

label-muted = " 奄 %percentage%%"
label-muted-foreground = #ffeec484

ramp-volume-0 = " 奄"
ramp-volume-0-foreground = #efdd6359
ramp-volume-1 = " 奔"
ramp-volume-2 = " 墳"
spacing = 2

label-volume = "%percentage%% "

format-volume-foreground = #ffeec484
#format-volume-underline = ${xrdb:polybar.color4}
format-volume-background = #7addb474
#format-muted-underline = ${xrdb:polybar.color4}

click-right = pavucontrol

CPU

Average CPU percentage.

[module/cpu]
type = internal/cpu
interval = 1
format-prefix = " "
format-foreground = #efdd6359
#format-underline = ${xrdb:polybar.color14}
format-background = #6acd5349
format-prefix-foreground = #ffdd6359
format-padding = 1
label = %percentage:2%%

Memory

Percentage of RAM in use.

[module/memory]
type = internal/memory
interval = 1
format-prefix = " "
format-padding = 1
format-foreground = #ef63b268
#format-underline = ${xrdb:polybar.color16}
format-background = #6a539f58
format-prefix-foreground = #ff63b268
label = %percentage_used%%

Battery

Notice the animations, and the red and yellow colors, to draw attention to low battery levels.

[module/battery]
type = internal/battery
battery = BAT0
adapter = AC0
full-at = 98

format-foreground = #efe99781
format-charging-foreground = #efe99781
format-charging-background = #7ad98771

format-charging = <animation-charging> <label-charging> 
#format-charging-underline = ${xrdb:polybar.color8}
format-charging-padding = 1

format-discharging-foreground = #efedc5c5
format-discharging-prefix-foreground = #efe99781
format-discharging = <ramp-capacity> <label-discharging>
#format-discharging-underline = ${xrdb:polybar.color8}
format-discharging-background = #7ad98771

format-discharging-padding = 1

format-full-prefix = " "
format-full-prefix-foreground = #efe99781
format-full-foreground = #efe99781
#format-full-underline = ${xrdb:polybar.color8}
format-full-background = #00000000

format-full-padding = 1

ramp-capacity-4 = ""
ramp-capacity-3 = ""
ramp-capacity-2 = ""
ramp-capacity-1 = ""
ramp-capacity-0 = ""
ramp-capacity-1-foreground = #efeec484
ramp-capacity-0-foreground = #efdd6359
ramp-capacity-foreground = #efe99781

animation-charging-0 = ""
animation-charging-1 = ""
animation-charging-2 = ""
animation-charging-3 = ""
animation-charging-4 = ""
animation-charging-foreground = #efe99781
animation-charging-framerate = 400

Date

Tried and true date module.

[module/date]
type = internal/date
interval = 1

format-prefix = " "

date = " %a %b %d"

time = " %I:%M:%S"

format-foreground = #ef78c4c1
format-prefix-foreground = #ef78c4c1
#format-underline = ${xrdb:polybar.color18}
format-background = #6b489390

label = %date% %time%

Author: Tanner Babcock

Created: 2022-10-30 Sun 18:39