A criminally short guide to installing polybar
on Ubuntu 20.04
polybar
is an excellent tool for creating customized, beautiful desktop status bars. It's available for almost all Unixes, some available through package managers, and for the others, you need to compile the source code by your own which sometimes might be painful 😿 .
Introduction
polybar
is not available for Focal
through apt
, so we will go through compiling it in this guide. This guide includes a solution to almost all errors you will likely encounter during the procedure, but if you face a new error, feel free to ask in the comments.
Prerequisite
In this guide, I will be using brew
to install some dependencies. If you've not installed it yet, give it a try by following the official procedure.
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
This will install homebrew
on your machine in a single easy step.
Instruction
- Clone the repository
$ git clone https://github.com/polybar/polybar.git
- Install dependencies through
apt
$ sudo apt-get install cmake cmake-data libcairo2-dev libxcb1-dev libxcb-ewmh-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-randr0-dev libxcb-util0-dev libxcb-xkb-dev pkg-config python3-xcbgen xcb-proto libxcb-xrm-dev i3-wm libasound2-dev libmpdclient-dev libiw-dev libcurl4-openssl-dev libpulse-dev python3-sphinx libxcb-composite0-dev libuv1-dev libuv1 libjsoncpp-dev
- Install additional dependencies through
brew
$ brew install cairo libuv alsa-lib libmpdclient
- Fix
Missing required python module: xcbgen
This occurs when you have multiple Python versions installed. You can see the issue on Github.
To fix it, you need to create a symlink
between the Python version with the module and the Python version behind python3
. You can check this by executing
$ python3 --versionPython 3.9.10
Then create a symlink like this
$ ln -s /usr/lib/python3.10/site-packages/xcbgen /usr/lib/python3.9/site-packages/
Note: The exact path here might differ depending on how you install python. For example if you have used brew
to install Python, it locates inside /home/linuxbrew/.linuxbrew/lib/
rather than /usr/lib/
.
- Building
For building just change the directory to the where polybar
is cloned and run build.sh
$ cd polybar && ./build.sh** Fetching submodules** A build dir already exists (pass -f to replace)** Setting build options** Use GCC even if Clang is installed ----------------------------- [y/N]: Y** Include support for "internal/i3" (requires i3) ---------------- [y/N]: Y** Include support for "internal/alsa" (requires alsalib) --------- [y/N]: Y** Include support for "internal/pulseaudio" (requires libpulse) -- [y/N]: N** Include support for "internal/network" (requires libnl/libiw) -- [y/N]: Y** Include support for "internal/mpd" (requires libmpdclient) ----- [y/N]: Y** Include support for "internal/github" (requires libcurl) ------- [y/N]: Y** Build "polybar-msg" used to send ipc messages ------------------ [y/N]: Y** Parallelize the build using make -j16 --------------------------- [y/N]: Y** Using compiler: clang++/clang
After executing, it asks if you need various components to be supported, e.g., PulseAudio
. Be sure to install components you need
When prompted to install the binary answer y
to install the library
- Test the installation Execute the following to see if
polybar
is installed correctly
$ polybar example
Final thoughts
Congratulation! You’ve successfully installed polybar
. Take a look at the official wiki for further customization. If you're looking for some motivation, take a look at unixporn, where you can find brilliant ideas to customize your own environments.