Polybar + Plasma 🫰 | Using Polybar with KDE plasma

2023-06-28

Backstory

I love using KDE’s Plasma. In my opinion, it is the most easily customizable and perfect desktop environment out there. While Plasma’s panels are undeniably awesome, I believe that Polybar has some advantages over them.

While configuring polybar with plasma on my machine I ended up wasting a lot of time debugging expected behaviors, so I writing a small and simple guide on how you can use polybar with plasma 😁.

So here it goes…

Installing Polybar

As I am using KDE neon, a Debian-based distribution based on Ubuntu LTS (22.04) running Plasma 5.27.6, I will follow the official documentation’s recommendation to compile polybar for my system. For other distribution refer to the installation documentation to install polybar.

Prerequisite

Install the HARD dependencies

$ sudo apt install build-essential git cmake cmake-data pkg-config python3-sphinx python3-packaging libuv1-dev libcairo2-dev libxcb1-dev libxcb-util0-dev libxcb-randr0-dev libxcb-composite0-dev python3-xcbgen xcb-proto libxcb-image0-dev libxcb-ewmh-dev libxcb-icccm4-dev

Install the OPTIONAL dependencies

NOTE: Only install the dependencies you need, list with all the description can be found here

$ sudo apt install libxcb-xkb-dev libxcb-xrm-dev libxcb-cursor-dev libasound2-dev libpulse-dev i3-wm libjsoncpp-dev libmpdclient-dev libcurl4-openssl-dev libnl-genl-3-dev

Compiling and Installing

Download the latest archive from the repository’s release page here and extract it using the command tar xvzf polybar-<version>.tar.

Then cd into the extracted folder: cd polybar-<version>

Proceed with the below instructions to install polybar

$ mkdir build
$ cd build
$ cmake ..
$ make -j$(nproc)
# Optional. This will install the polybar executable in /usr/local/bin
$ sudo make install

After completing the installation process, Polybar should be installed on your system. To verify the installation, run the command $ polybar. Upon executing the command, a default Polybar should appear at the top of your screen.

Next steps

  • Copy the example configuration from /etc/polybar/config.ini to the ~/.config/polybar directory

    $ cp /etc/polybar/config.ini ~/.config/polybar/
    
    • Now you should be able to launch the example configuration using $ poly example & command
  • To customize the bar you can follow the official configuration documentation

Launching the script on startup

This was the part that wasted a lot of my time and made me question my sanity, so for polybar the general login script option doesn’t work because the login scripts runs before the desktop environment loads so instead we will be using the Application option to run polybar

  • Go to System Setting > Workspace > Startup and Shutdown > Autostart An image showing User Interface of Tokodon&rsquo;s Account Moderation Tool
  • Click on the + Add… button and selected + Add Application… An image showing User Interface of Tokodon&rsquo;s Account Moderation Tool
  • In the pop-up dialog type polybar and select the Run in terminal option. Click on OK An image showing User Interface of Tokodon&rsquo;s Account Moderation Tool
  • In the next dialog go to Application tab and under arguments text field type example & (here example is the name of your bar) and click on OK.

Now restart your machine and polybar should be launched as expected : )

Using feh to set wallpaper

Polybar recommends setting wallpaper using feh or nitrogen. I faced Cannot find root pixmap, try a different tool to set the desktop background error while using the default plasma wallpaper settings.

  • To fix this I simply installed feh using my distro package manager.
$ sudo apt install feh
  • Then set the same wallpaper using feh
$ feh --bg-scale <path to wallpaper> 
  • Set the above feh script to autostart at startup in the same way as polybar An image showing User Interface of Tokodon&rsquo;s Account Moderation Tool

  • Restart your machine and everything should work as expected.

Final result

I am using plasma floating panel + polybar + bismuth for the below rice

An image showing User Interface of Tokodon&rsquo;s Account Moderation Tool An image showing User Interface of Tokodon&rsquo;s Account Moderation Tool

Reference: https://github.com/polybar/polybar/wiki/