A Better Status Bar - Polybar

Anybody who has used a window manager on Linux, such as i3 or bspwm, knows that it can be tedious and time consuming to setup status bars. This is where...

9 months ago

Latest Post Automatic Offline Backup With a Raspberry Pi by Tyler Moon

Anybody who has used a window manager on Linux, such as i3 or bspwm, knows that it can be tedious and time consuming to setup status bars. This is where the Polybar project comes to the rescue as this tool makes it much easier to quickly and easily configure status bars for just about any Linux WM. This open source project has a nice installer, uses a single INI format config file, and has a helpful GitHub community.

Note: This article explains how to install and use Polybar specifically on Arch Linux. However, Polybar works on most common Linux distros so you may have to switch the package manager commands to the correct one for your distro.

Prerequisites

Install

To install the Polybar tool run the following command:

yaourt -S polybar

# If you do not have yaourt then you can use the default arch package manager
# sudo pacman -S polybar

Now run polybar --help to verify it installed correctly. By default the example config file is located in /usr/share/doc/polybar/config but its best to move it into your home directory.

install -Dm644 /usr/share/doc/polybar/config $HOME/.config/polybar/config

And that is it for the Polybar part of the install, however, by default Arch is missing a font which is needed for the example bar to work correctly. The Siji font can be installed by running

yaourt -S siji-git
xset +fp $HOME/.local/share/fonts
xset fp rehash

Configuration

Open up the $HOME./config/polybar/config file and change the font configs to the following:

font-0 = terminus:pixelsize=12;1
font-1 = unifont:fontformat=truetype:size=10:antialias=false;0
font-2 = "Wuncon Siji:pixelsize=12;1"

Then run polybar example and a new status bar should appear on the top of your screen. As far as WM status bars goes that is about as easy as it gets.

Replace i3 status bar

Now that we have a Polybar setup ready to go we need to replace the existing i3 status bar and have our new Polybar run on startup. To do so open up the i3 config file at $HOME/.config/i3/config and replace:

# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
        status_command i3status
}

with

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

Then reload the i3 instance with the mod+shift+r shortcut and the i3 status bar should disappear and the Polybar should appear.

Further Configuration

With this basic setup in place you can now tweak the Polybar config file to your needs / liking. Checkout the wiki for more specific details on how to configure modules and add new ones.

Summary

In this article we saw how to replace the boring ugly i3 status bar with a Polybar. This tool helps create useful status bars while still keeping to the lightweight, minimal, functional mindset of window managers.

Tyler Moon

Published 9 months ago

Comments?

Leave us your opinion.