Polybar
Polybar is Article description::a fast and easy-to-use status bar. It allows building customizable status bars for various desktop environments. Currently, bspwm and i3wm are supported off the shelf.
Installation
USE flags
USE flags for x11-misc/polybar A fast and easy-to-use tool for creating status bars
alsa
|
Add support for media-libs/alsa-lib (Advanced Linux Sound Architecture) |
curl
|
Add support for client-side URL transfer library |
doc
|
Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally |
i3wm
|
Add support for i3 window manager |
ipc
|
Add support for Inter-Process Messaging |
mpd
|
Add support for Music Player Daemon |
network
|
Enable network support |
pulseaudio
|
Add support for PulseAudio sound server |
Emerge
root #
emerge --ask x11-misc/polybar
Configuration
The Polybar package brings a sample configuration file which is installed at /usr/share/doc/polybar-*/config.bz2. This file demonstrates different configuration options, but cannot be used directly.
A working sample would look as follows:
~/.config/polybar/config
<syntaxhighlight lang="ini">[bar/mybar] modules-left = i3 modules-right = lan wlan filesystem cpu date tray-position = right font-0 = Noto Sans Mono:style=Regular [colors] black = #000 white = #fff grey = #aaa darkgrey = #555 red = #f00 green = #0f0</syntaxhighlight>
This declares a new bar called "mybar"
, and identifies which modules are being used and instructs polybar to create a systray for hosting applets. The optional section [colors]
makes it easier to use colors in the different modules.
Each declared module needs further configuration, which is described in the next chapters.
Date
The following section adds date and time to the bar.
~/.config/polybar/config
<syntaxhighlight lang="ini">[module/date] type = internal/date ;interval = 1 date = " | %d-%h-%y %H:%M:%</syntaxhighlight>
Increase the interval to reduce power consumption.
Filesystem
For monitoring the disk space utilization of various mount points:
~/.config/polybar/config
<syntaxhighlight lang="ini">[module/filesystem]
type = internal/fs
interval = 60
mount-0 = /
mount-1 = /tmp
mount-2 = /data
label-mounted = %{F#0a81f5}%mountpoint%%{F-}: %percentage_used%%</syntaxhighlight>
LAN
The following section shows the network status for a wired LAN:
~/.config/polybar/config
<syntaxhighlight lang="ini">[module/lan] type = internal/network interface = eth0 label-connected = "%ifname%: %local_ip% %local_ip6% | " ;label-disconnected = "%ifname%: not connected | "</syntaxhighlight>
Update the interface line as required.
WLAN
The Wifi wireless LAN section is almost identical as the wired LAN section, but has a few more things to show.
~/.config/polybar/config
<syntaxhighlight lang="ini">[module/wlan] type = internal/network interface = wlan0 label-connected = "%ifname%: %essid% %signal%% %{F#00F000}%local_ip% %{F#F000F0}%local_ip6% %{F-} | " ;label-disconnected = "%ifname%: not connected | "</syntaxhighlight>
CPU
To show processor utilization the following section can be used:
~/.config/polybar/config
<syntaxhighlight lang="ini">[module/cpu] type = internal/cpu format = <label> <ramp-coreload> label = " | CPU %percentage%%" ramp-coreload-spacing = 1 ramp-coreload-0 = %{F#0a0}▁%{F-} ramp-coreload-1 = %{F#0a0}▂%{F-} ramp-coreload-2 = %{F#0a0}▃%{F-} ramp-coreload-3 = %{F#0a0}▄%{F-} ramp-coreload-4 = %{F#f80}▅%{F-} ramp-coreload-5 = %{F#f80}▆%{F-} ramp-coreload-6 = %{F#f00}▇%{F-} ramp-coreload-7 = %{F#f00}█%{F-}</syntaxhighlight>
This section uses the ramp option to graphically show the utilization per core, showing low utilization as green, mid utilization as orange and high utilization as red. Note that the colors section cannot be reused here.
Integration with i3 window manager
Polybar can replace i3bar. This requires following steps.
Configure Polybar's i3 module
In case Polybar is used with the i3 window manager the following can be used to configure the Polybar's i3 module:
~/.config/polybar/config
<syntaxhighlight lang="ini">[module/i3] type = internal/i3 label-focused = %index% label-focused-background = ${colors.darkgrey} label-focused-foreground = ${colors.white} label-focused-underline= ${colors.primary} label-focused-padding = 1 label-unfocused = %index% label-unfocused-foreground = ${colors.grey} label-unfocused-padding = 1 label-urgent = %index% label-urgent-foreground = ${colors.white} label-urgent-background = ${colors.red} label-urgent-padding = 1</syntaxhighlight>
Create Polybar launch script
~/.config/polybar/launch
<syntaxhighlight lang="bash">#!/bin/bash # Terminate already running bar instances killall -q polybar # Wait until the processes have been shut down while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done # Launch Polybar, using default config location ~/.config/polybar/config polybar mybar & echo "Polybar launched..."</syntaxhighlight>
Replacing i3bar with polybar
Comment out the following section that starts i3bar, and add a statement to launch polybar:
~/.config/i3/config
# Start i3bar to display a workspace bar (plus the system information i3status # finds out, if available) #bar { # font pango:DejaVu Sans Mono 10 # position top # status_command i3status #} # use polybar instead of i3bar exec_always --no-startup-id ~/.config/polybar/launch
Removal
To remove Polybar issue the following:
root #
emerge --verbose --ask --depclean x11-misc/polybar
Do not forget to remove the added files under ~/.config/polybar/ and to restore the i3bar section in ~/.config/i3/config.
See also
- bspwm — a lightweight, tiling, minimalist window manager that is written in C and represents its windows as leaves on a binary tree.
- i3 — a minimalist tiling window manager, completely written from scratch.