polybar.org 12 KB

Basic settings

Below are the main settings, inherited by all other sections


[core_settings]
; Thin bar height
height = 16

; No radius for square bar
radius = 0.0

; Font updated to show correct font
font-0 = "LiterationMono Nerd Font:size=10;2"
font-1 = "LiterationMono Nerd Font:size=14;3"
font-2 = "LiterationMono Nerd Font:size=9;2"

; No padding, so bar touches screen edges
padding-left = 0
padding-right = 0

; Small margins between modules
module-margin-left = 0
module-margin-right = 1

; Keep lines thin
line-size = 1
line-color = ${colors.cat_focus_foreground}

; Fill the screen
width = 100%

Bar Setup

These sections set out the order of the bars

Top Bar

The below details the configuration of the top bar.


[bar/topbar]
inherit = core_settings

bottom = false

; Used modules
modules-center = battery temperature cpu memory gpu
modules-left = filesystem
modules-right = wlan eth

; Keep centre modules in the centre
fixed-center = true

; Black BG & White text
background = ${colors.cat_black}
foreground = ${colors.cat_light_text}

; Thin black border between bar & windows
border-size = 2
border-color = ${colors.cat_black}

Bottome Bar

The following constructs the bottom bar


[bar/bottombar]
inherit = core_settings

; Thicker bottom bar
height = 18

bottom = true

; Used modules
modules-left = i3
modules-center = date
modules-right = pulseaudio

; Keep centre modules in the centre
fixed-center = true

; Black BG & White text
background = ${colors.cat_black}
foreground = ${colors.cat_light_text}

; Thin black border between bar & windows
border-size = 0
border-color = ${colors.cat_black}

; System tray
tray-position = right
tray-padding = 2
tray-background = ${colors.cat_black}

External scripts

The below script will kill the polybar setup, and launch a refershed version

Relaunch script

Simple script to kill the current polybar, and begin again

Save the below script as ​~~/bin/polylaunch.sh~, and make executable


#!/bin/bash

# Terminate already running bar instances
killall -q polybar

# Launch topbar and bottombar
echo "---" | tee -a /tmp/polybar-topbar.log /tmp/polybar-bottombar.log
polybar topbar 2>&1 | tee -a /tmp/polybar-topbar.log & disown
polybar bottombar 2>&1 | tee -a /tmp/polybar-bottombar.log & disown

echo "Bars launched..."

GFX State script

Simple bash cripte to return the state of the NVIDIA discreetGPU on my Thinkad W520

Save the below script as ​~~/bin/polygfxcheck.sh~, and maek executable


#!/bin/bash
STATUS=$(cat /proc/acpi/bbswitch | grep -o -E "ON|OFF")

if [ $STATUS = "ON" ]; then
    echo "%{F#f00}ON%{F-}"
else
    echo $STATUS
fi

Colours

This sets the colours to (somewhat) match my i3 setup.

Personal colour tags are all prefixed with "cat_", and referenced later in the document


[colors]
; Personal colours all prefixed with cat_
cat_focus_foreground = #04f700
cat_focus_background = #196d13

cat_unfocus_foreground = #333333
cat_unfocus_background = #222222

cat_urgent_foreground = #ff0000
cat_urgent_background = #700e0e

cat_light_text = #ffffff
cat_dark_text = #888888
cat_green_text = #92ff92

cat_black = #000000
cat_orange = #e28008

Polybar Modules

Filesystem

Filesystem display is here, showing available space in a human readable format


[module/filesystem]
type = internal/fs
interval = 25

mount-0 = /
; mount-1 = /home

label-mounted = %{F#888888}%{F#92ff92} %mountpoint%%{F-}: %free%/%total% free
label-unmounted = %mountpoint% unmounted
label-unmounted-foreground = ${colors.cat_dark_text}

spacing = 2

i3

This code highlights the i3 workspaces, using self-defined colours that match the rest of my i3 setup


[module/i3]
type = internal/i3
format = <label-state> <label-mode>
index-sort = true
wrapping-scroll = false

; mode
label-mode-padding = 1
label-mode-foreground = ${colors.cat_light_text}
label-mode-background = ${colors.cat_focus_background}

; focused = Active workspace on focused monitor
label-focused = %index%
label-focused-background = ${colors.cat_focus_background}
label-focused-underline = ${colors.cat_focus_foreground}
label-focused-foreground = ${colors.cat_light_text}
label-focused-padding = 1

; unfocused = Inactive workspace on any monitor
label-unfocused = %index%
label-unfocused-background = ${colors.cat_unfocus_background}
label-unfocused-underline = ${colors.cat_unfocus_foreground}
label-unfocused-foreground = ${colors.cat_dark_text}
label-unfocused-padding = 1

; visible = Active workspace on unfocused monitor
label-visible = %index%
label-visible-background = ${self.label-focused-background}
label-visible-underline = ${self.label-focused-underline}
label-visible-padding = ${self.label-focused-padding}

; urgent = Workspace with urgency hint set
label-urgent = %index%
label-urgent-background = ${colors.cat_urgent_background}
label-urgent-underline = ${colors.cat_urgent_foreground}
label-urgent-foreground = ${colors.cat_light_text}
label-urgent-padding = 1

; Disabled separator in between workspaces
;label-separator = |

CPU Usage

Show CPU utilization


[module/cpu]
type = internal/cpu
interval = 1
format-prefix = "ﲾ "
format-prefix-foreground = ${colors.cat_dark_text}
format-underline = ${colors.cat_focus_foreground}
label = %percentage:2%%

Memory usage

Show how much RAM is currently being used


[module/memory]
type = internal/memory
interval = 1
format-prefix = " "
format-prefix-foreground = ${colors.cat_dark_text}
format-underline = ${colors.cat_focus_foreground}
label = %percentage_used%%

GPU notification

This module will show the current state of the GPU (reliant upon GFX State script)


[module/gpu]
; Run a simple script to check the power state of the NVidia GPU using bbswitch
type = custom/script
exec = ~/bin/polygfxcheck.sh
interval = 5
format-prefix = "ﳻ "
format-prefix-foreground = ${colors.cat_dark_text}
format-prefix-font = 2
format-underline = ${colors.cat_focus_foreground}
click-right = polygfxmenu.sh

Network Stats

Shows state of current netowrk connection - interfaces can be found wit ip link on the terminal

WiFi network


[module/wlan]
type = internal/network
interface = wlp3s0
interval = 3

format-connected = <ramp-signal> <label-connected>
format-connected-underline = ${colors.cat_focus_foreground}
label-connected = %essid% | %local_ip% | 說 %signal%% | %downspeed% | 祝%upspeed%

format-disconnected = <label-disconnected>
format-disconnected-underline = ${colors.cat_urgent_foreground}
label-disconnected = 睊 %ifname%
label-disconnected-foreground = ${colors.cat_dark_text}

ramp-signal-0 = 直
ramp-signal-foreground = ${colors.cat_dark_text}

Wired network


[module/eth]
type = internal/network
interface = enp0s25
interval = 3

format-connected-underline = ${colors.cat_focus_foreground}
format-connected-prefix = " "
format-connected-prefix-foreground = ${colors.cat_dark_text}
label-connected = %local_ip% | %linkspeed%

format-disconnected = <label-disconnected>
format-disconnected-underline = ${colors.cat_urgent_background}
format-disconnected-prefix = " "
format-disconnected-prefix-foreground = ${colors.cat_dark_text}
label-disconnected = no %ifname%
label-disconnected-foreground = ${colors.cat_dark_text}

Date/Time display

Show the current date and time, click to simplify


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

; Main mode has "written" date with simple time 
;date = " %A %d %B %Y "
;time = " %H:%M"
date = %{F#888888}%{F-} %A %d %B %Y
time = %{F#888888}%{F-} %H:%M

; Alt mode has ISO date with complete clock (including seconds)
date-alt = %{F#888888}%{F-} %Y-%m-%d
time-alt = %{F#888888}%{F-} %T %Z

; Hide prefix, update underline to match i3 settings
;format-prefix = 
format-underline = ${colors.cat_focus_foreground}
format-foreground = ${colors.cat_light_text}
format-padding = 1

; Display date then time
label = %date% %time%

Volume Widget

The below shows a volume widget, that can be altered by the mouse scroll-wheel


[module/pulseaudio]
type = internal/pulseaudio

format-volume = <label-volume> <bar-volume>
label-volume =  %percentage%%
label-volume-foreground = ${colors.cat_light_text}

label-muted =  muted
label-muted-foreground = ${colors.cat_dark_text}

bar-volume-width = 10
bar-volume-foreground-0 = ${colors.cat_focus_background}
bar-volume-foreground-1 = ${colors.cat_focus_background}
bar-volume-foreground-2 = ${colors.cat_focus_background}
bar-volume-foreground-3 = ${colors.cat_focus_background}
bar-volume-foreground-4 = ${colors.cat_focus_background}
bar-volume-foreground-5 = ${colors.cat_orange}
bar-volume-foreground-6 = ${colors.cat_orange}
bar-volume-foreground-7 = ${colors.cat_urgent_background}
bar-volume-gradient = true
bar-volume-indicator = 
bar-volume-indicator-font = 2
bar-volume-indicator-foreground = ${colors.cat_green_text}
bar-volume-fill = ▓
;bar-volume-fill = =
bar-volume-fill-font = 1
bar-volume-empty = -
bar-volume-empty-font = 1
bar-volume-empty-foreground = ${colors.cat_dark_text}

Battery Stats

Show current battery state (level/charging/AC/etc)


[module/battery]
type = internal/battery
battery = BAT0
adapter = AC
full-at = 95

format-charging = <animation-charging> <label-charging>
format-charging-underline = ${colors.cat_orange}

format-discharging = <animation-discharging> <label-discharging>
format-discharging-underline = ${colors.cat_urgent_foreground}

format-full-prefix = ""
format-full-prefix-foreground = ${colors.cat_dark_text}
format-full-underline = ${colors.cat_focus_foreground}

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 = ${colors.cat_dark_text}

animation-charging-0 = 
animation-charging-1 = 
animation-charging-2 = 
animation-charging-3 = 
animation-charging-4 = 
animation-charging-5 = 
animation-charging-6 = 
animation-charging-7 = 
animation-charging-8 = 
animation-charging-9 = 
animation-charging-foreground = ${colors.cat_dark_text}
animation-charging-framerate = 300

animation-discharging-0 = 
animation-discharging-1 = 
animation-discharging-2 = 
animation-discharging-3 = 
animation-discharging-4 = 
animation-discharging-5 = 
animation-discharging-6 = 
animation-discharging-7 = 
animation-discharging-8 = 
animation-discharging-9 = 
animation-discharging-foreground = ${colors.cat_dark_text}
animation-discharging-framerate = 300

CPU temp

Display current CPU temperature


[module/temperature]
type = internal/temperature
thermal-zone = 1
warn-temperature = 60

format = <ramp> <label>
format-underline = ${colors.cat_focus_foreground}
format-warn = <ramp> <label-warn>
format-warn-underline = ${colors.cat_urgent_foreground}

label = %temperature-c%
label-warn = %temperature-c%
label-warn-foreground = ${colors.cat_urgent_foreground}

ramp-0 = 
ramp-1 = 
ramp-2 = 
ramp-3 = 
ramp-4 = 
ramp-foreground = ${colors.cat_dark_text}

Miscellaneous Settings

General settings


[settings]
screenchange-reload = true
pseudo-transparency = false

WM Margins

Window manager margin settings


[global/wm]
; Slim margins on bar
margin-top = 1
margin-bottom = 1