Polybar

From ArchWiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

polybar is a fast and easy-to-use tool for creating status bars. It aims to be easily customizable, utilising many modules which enable a wide range of (editable) functionality, such as displaying workspaces, the date, or system volume. Polybar is especially useful for window managers that have a limited or non-existent status bar, such as awesome or i3. Polybar can also be used with desktop environments like Plasma.

Installation

Install the polybarAUR package. The development version is polybar-gitAUR.

Configuration

Copy the configuration example from /usr/share/doc/polybar/config to $XDG_CONFIG_HOME/polybar/config.

Running Polybar

Polybar can be run with the following arguments:

Usage: polybar [OPTION]... BAR

  -h, --help               Display this help and exit
  -v, --version            Display build details and exit
  -l, --log=LEVEL          Set the logging verbosity (default: WARNING)
                           LEVEL is one of: error, warning, info, trace
  -q, --quiet              Be quiet (will override -l)
  -c, --config=FILE        Path to the configuration file
  -r, --reload             Reload when the configuration has been modified
  -d, --dump=PARAM         Print value of PARAM in bar section and exit
  -m, --list-monitors      Print list of available monitors and exit
  -w, --print-wmname       Print the generated WM_NAME and exit
  -s, --stdout             Output data to stdout instead of drawing it to the X window
  -p, --png=FILE           Save png snapshot to FILE after running for 3 seconds

However you will probably want to run Polybar with your window manager's bootstrap routine. See #Running with WM.

Sample configuration

A very basic polybar configuration may look like this:

[bar/mybar]
modules-right = date

[module/date]
type = internal/date
date = %Y-%m-%d%

It defines a bar named mybar with a module called date.

By default polybar will also install a sample configuration with many preconfigured modules in /usr/share/doc/polybar/config.

Note: The sample configuration is not designed to work out of the box for everyone. You will need to modify it to match your setup.

Running with WM

Create an executable file containing the startup logic, for example $HOME/.config/polybar/launch.sh:

#!/bin/bash

# Terminate already running bar instances
killall -q polybar
# If all your bars have ipc enabled, you can also use 
# polybar-msg cmd quit

# Launch Polybar, using default config location ~/.config/polybar/config
polybar mybar 2>&1 | tee -a /tmp/polybar.log & disown

echo "Polybar launched..."

This script will mean that restarting your WM will also restart Polybar.

bspwm

If using bspwm, add the following to bspwmrc:

$HOME/.config/polybar/launch.sh

i3

If using i3, add the following to your i3 configuration:

exec_always --no-startup-id $HOME/.config/polybar/launch.sh

Troubleshooting

Cannot open shared object file libjsoncpp.so

Attempt a reinstall as described in the issue on the GitHub.

Failing that, try to install the jsoncpp package.

See also