PRIMARY CATEGORY → DESKTOP SETUP

POLYBAR → Highly Customizable Status Bars

Each bar has its own modules and It is executed as a daemon

$ pgrep --list-full --exact polybar
1631 polybar log -c /home/al3xbb/.config/polybar/current.ini
1632 polybar ethernet_bar -c /home/al3xbb/.config/polybar/current.ini
1633 polybar vpn_bar -c /home/al3xbb/.config/polybar/current.ini

A module can execute any action such as a command, scripts…

Each bar with its configuration file as an argument is launched by the below script

Polybar is executed by bspwm from the bspwmrc script through the polybar’s launcher script → ~/.config/polybar/launch.sh

~/.config/bspwm/bspwmrc
# Polybar Launch
checkProcess polybar || { launchProcess "$_pbl" ; unset -v -- _pbl ; }

Configuration File → Any file which a .ini extension

Launcher File → ~/.config/polybar/launch.sh

More information here

Polybar Site


Installation

apt install -y -- polybar

That’s it!

$ command -V polybar
polybar is /usr/bin/polybar

As a base for the configuration file’s structure, clone the following Github Repository

Reference

git clone https://github.com/VaughnValle/blue-sky ~/Downloads/blue-sky

Then, recursively copy the polybar’s content into ~/.config/polybar

cd !$
bash -c "shopt -sq dotglob && cp -rv -- ./polybar/* ~/.config/polybar"

Once the above is done, insert the following line in the bspwmrc file related to the Polybar’s Launch

As already stated, these functions check polybar’s status and launch it

~/.config/bspwm/bspwmrc
checkProcess polybar || { launchProcess "$_pbl" ; unset -v -- _pbl ; }

Lastly, copy the polybar’s fonts (i.e. the .ttf Files) into the system TrueType Fonts directory and reset the _ system’s fonts cache_ →

cp ~/.config/polybar/fonts/* /usr/share/fonts/truetype/
fs-cache -v # Reset the System Fonts Cache

Configuration File

Current.ini

See here

Most of the Bars and their Modules are defined in this Configuration File

Workspace.ini

See here

This Configuration File contains the Main Bar’s definition related to the Windows Manager Workspaces


Launcher File

Launch.sh

See here

This shell script launchs all the Bars defined in the above configuration files


Bars

A bar can contain one or several modules

There is a distinction between the position of the Top Bars

  • Left Bar
  • Center Bar
  • Right Bar

Left
os_icon

It is launched from the launch.sh script as follows →

~/.config/polybar/launch.sh
polybar os_icon -c ~/.config/polybar/current.ini &

Module processed within the bar → my-text-label

~/.config/polybar/current.ini
modules-center = my-text-label # Module Loaded

ethernet_bar

It is launched from the launch.sh script as follows →

~/.config/polybar/launch.sh
polybar ethernet_bar -c ~/.config/polybar/current.ini &

Module processed within the bar → ethernet_status

~/.config/polybar/current.ini
modules-center = ethernet_status # Module Loaded

vpn_bar

It is launched from the launch.sh script as follows →

~/.config/polybar/launch.sh
polybar vpn_bar -c ~/.config/polybar/current.ini &

Module processed within the bar → vpn_status

~/.config/polybar/current.ini
modules-center = vpn_status # Module Loaded

Center
primary

It is launched from the launch.sh script as follows →

~/.config/polybar/launch.sh
polybar primary -c ~/.config/polybar/workspace.ini &

Module processed within the bar → workspaces

~/.config/polybar/workspace.ini
modules-center = workspaces # Module Loaded

target_to_hack

It is launched from the launch.sh script as follows →

~/.config/polybar/launch.sh
polybar target_to_hack -c ~/.config/polybar/current.ini &

Module processed within the bar → target_to_hack

~/.config/polybar/current.ini
modules-center = target_to_hack # Module Loaded

primary

It is launched from the launch.sh script as follows →

~/.config/polybar/launch.sh
polybar primary -c ~/.config/polybar/current.ini &

Module processed within the bar → sysmenu

~/.config/polybar/current.ini
modules-center = sysmenu # Module Loaded


Modules

A module is a execution unit that can perform a specific action within a bar, such as run a script

One or several modules can be processed in the same bar

my-text-label

It simply displays the icon specified in the content parameter

Associated Bar → os_icon

Module definition →

~/.config/polybar/current.ini
[module/my-text-label]
type = custom/text
content = %{T7}
Font

See here to install the Hack Nerd Fonts

The content parameter above uses the T7 Font Type

This Font Type is not declared by default

Chosen Font → Hack Nerd Font

To declare it and set the size and position of the OS Icon

~/.config/polybar/current.ini
font-7 = "Hack Nerd Font Mono:size=20;6" # Filter by 'font-' in the above file
ethernet_status

This module executes the specified script through the exec parameter every two seconds

Associated Bar → ethernet_bar

Module definition →

~/.config/polybar/current.ini
[module/ethernet_status]
type = custom/script
interval = 2
exec = ~/.config/bspwm/bin/ethernet_status.sh
modules/ethernet_status.sh

Reference

It displays the IP Address assigned to a specific Network Interface

vpn_status

This module executes the specified script through the exec parameter every two seconds

Associated Bar → vpn_bar

Module definition →

~/.config/polybar/current.ini
[module/vpn_status]
type = custom/script
interval = 2
exec = ~/.config/bspwm/bin/vpn_status.sh
modules/vpn_status.sh

Reference

It displays the IP Address assigned to the VPN Network Interface (Tun0)

Shell Functions

The following shell functions performs the following actions to the above file (target) →

  • setTarget → Prints the IP Address and Hostname of the target

sysmenu

This module performs the following actions →

  • Icon Display via the content parameter
  • Executes the specified script in the click-left parameter

Associated Bar → primary

Module definition →

~/.config/polybar/current.ini
[module/sysmenu]
type = custom/text
content =
click-left = ~/.config/polybar/scripts/powermenu_alt