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
INFO
In above command’s output, each process corresponds to a specific bar with its name and its configuration file where the bar and its module/s are declared
polybar log -c /home/al3xbb/.config/polybar/current.ini | | +---> Bar's Name +---> Config File
-c FILE | --config=FILE
→ Path to the configuration file
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
# Polybar Launch
checkProcess polybar || { launchProcess "$_pbl" ; unset -v -- _pbl ; }
INFO
Note that
checkProcess
andlaunchProcess
are shell functions declared in the~/.config/bspwm/src/bspwmrc.sh
source fileThe
$_pbl
parameter is also declared in that file being the Polybar Launcher PathAbove implementation would be something similar to the usual approach through
pgrep --exact process_name || binary|script_path &
#!/usr/bin/env sh pgrep --exact polybar > /dev/null 2>&1 || ~/.config/polybar/launch.sh &
Configuration File → Any file which a .ini
extension
Launcher File → ~/.config/polybar/launch.sh
More information here
Installation
CAUTION
apt install -y -- polybar
That’s it!
$ command -V polybar
polybar is /usr/bin/polybar
IMPORTANT
Installation can be done either through the OS package manager or via the
git clone
commandNote that the default OS repositories listed in
/etc/apt/sources.list
file and in/etc/apt/sources.list.d
directory may have older versions unlike thepolybar
’s official Github repositoryAs It is always is desirable to have the latest versions of any package or binary installed, I’d recommend installing them via their Github Repositories
Although, in this case the package’s version installed from the
apt
Package Manager differs only slightly from the github one
As a base for the configuration file’s structure, clone the following Github Repository
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"
INFO
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
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
Most of the Bars and their Modules are defined in this Configuration File
Workspace.ini
This Configuration File contains the Main Bar’s definition related to the Windows Manager Workspaces
Launcher File
Launch.sh
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 →
polybar os_icon -c ~/.config/polybar/current.ini &
Module processed within the bar → my-text-label
modules-center = my-text-label # Module Loaded
ethernet_bar
It is launched from the launch.sh script as follows →
polybar ethernet_bar -c ~/.config/polybar/current.ini &
Module processed within the bar → ethernet_status
modules-center = ethernet_status # Module Loaded
vpn_bar
It is launched from the launch.sh script as follows →
polybar vpn_bar -c ~/.config/polybar/current.ini &
Module processed within the bar → vpn_status
modules-center = vpn_status # Module Loaded
Center
primary
It is launched from the launch.sh script as follows →
polybar primary -c ~/.config/polybar/workspace.ini &
Module processed within the bar → workspaces
modules-center = workspaces # Module Loaded
Right
target_to_hack
It is launched from the launch.sh script as follows →
polybar target_to_hack -c ~/.config/polybar/current.ini &
Module processed within the bar → target_to_hack
modules-center = target_to_hack # Module Loaded
primary
It is launched from the launch.sh script as follows →
polybar primary -c ~/.config/polybar/current.ini &
Module processed within the bar → sysmenu
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 →
[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 →
font-7 = "Hack Nerd Font Mono:size=20;6" # Filter by 'font-' in the above file
INFO
Note that the
size
parameter sets both the OS Icon’s size and positionsize=SIZE;POSITION
ethernet_status
This module executes the specified script through the exec
parameter every two seconds
Associated Bar → ethernet_bar
Module definition →
[module/ethernet_status]
type = custom/script
interval = 2
exec = ~/.config/bspwm/bin/ethernet_status.sh
modules/ethernet_status.sh
It displays the IP Address assigned to a specific Network Interface
ethernet_status.sh
Delete Backslashes hiding the
%
characters#!/usr/bin/env bash printf "\%\%{F#2495e7} \%\%{F#ffffff}$( /usr/sbin/ifconfig ens33 | awk '/inet\s/ { print $2 }' )\%\%{u-}\n"
vpn_status
This module executes the specified script through the exec
parameter every two seconds
Associated Bar → vpn_bar
Module definition →
[module/vpn_status]
type = custom/script
interval = 2
exec = ~/.config/bspwm/bin/vpn_status.sh
modules/vpn_status.sh
It displays the IP Address assigned to the VPN Network Interface (Tun0)
vpn_status.sh
#!/usr/bin/env bash checkVPNiface () { local -- _vpnIface=$( /usr/sbin/ifconfig tun0 2> /dev/null ) if [[ -n $_vpnIface ]] ; then printf "{F#ffffff}$( /usr/sbin/ifconfig tun0 | awk '/inet\s/ { print $2 }' ){F#1bbf3e} {F#e51d0b} {F#ffffff} No target\n" } while IFS=: read -r _IP _machineName do printf "{F#ffffff}%s%%{u-} - %s\n" "$_machineName" "$_IP" done < "$_targetFile" } extractData
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
- clearTarget → Empties the file
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 →
[module/sysmenu]
type = custom/text
content = 襤
click-left = ~/.config/polybar/scripts/powermenu_alt