From Gentoo Wiki
Jump to:navigation Jump to:search
This article is a stub. You can help by expanding it.

Polybar is 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.

It is a good alternative for systems without PulseAudio.


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


root #emerge --ask x11-misc/polybar


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:

FILE ~/.config/polybar/config
modules-left = i3
modules-right = lan wlan filesystem cpu date
tray-position = right
font-0 = Noto Sans Mono:style=Regular

black = #000
white = #fff
grey = #aaa
darkgrey = #555
red = #f00
green = #0f0

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.


The following section adds date and time to the bar.

FILE ~/.config/polybar/config
type = internal/date
;interval = 1
date = " | %d-%h-%y %H:%M:%

Increase the interval to reduce power consumption.


For monitoring the disk space utilization of various mount points:

FILE ~/.config/polybar/config
type = internal/fs
interval = 60
mount-0 = /
mount-1 = /tmp
mount-2 = /data
label-mounted = %{F#0a81f5}%mountpoint%%{F-}: %percentage_used%%


The following section shows the network status for a wired LAN:

FILE ~/.config/polybar/config
type = internal/network
interface = eth0
label-connected = "%ifname%: %local_ip% %local_ip6% | "
;label-disconnected = "%ifname%: not connected | "

Update the interface line as required.


The Wifi wireless LAN section is almost identical as the wired LAN section, but has a few more things to show.

FILE ~/.config/polybar/config
type = internal/network
interface = wlan0
label-connected = "%ifname%: %essid% %signal%%  %{F#00F000}%local_ip% %{F#F000F0}%local_ip6% %{F-} | "
;label-disconnected = "%ifname%: not connected | "


To show processor utilization the following section can be used:

FILE ~/.config/polybar/config
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-}

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:

FILE ~/.config/polybar/config
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

Create Polybar launch script

FILE ~/.config/polybar/launch

# 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..."

Replacing i3bar with polybar

Comment out the following section that starts i3bar, and add a statement to launch polybar:

FILE ~/.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


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 window manager, focusing on keyboard commands to manipulate windows.