Waybar: An All-round Status Bar for most Window Managers

waybar
waybar statusbar for window managers

Linux users prefer status bars to have a quick look on key details like battery status and more. Waybar is a customizable status bar with options to customize as per the user’s needs. With a lot of in-built configuration options pre-loaded, Waybar is an easy choice for Linux users who prefer tailoring their status bars to suit their requirements. In this article, let us learn more about Waybar, its famous features, how to configure Waybar, and some practical uses as well.

What is Waybar?

As usual in Unixmen, we start with what we are going to learn about. For those using different status bars, Waybar is a status bar, designed to give its users a sleek and modular status bar for Linux window managers. Waybar supports a lot of modules like CPU usage, memory usage, and network bandwidth. All these modules can be tweaked to the user’s requirements, which lets users create a status bar that closely aligns with their functional and aesthetic choices.

Why is Waybar Famous?

  1. Highly customizable modules: The most favourite aspect is that it supports so many modules that display system status and information. In addition to that, each module can be configured to show specific details so that it is easy to monitor the metrics that are important to the user.
  2. Easily customizable: Anyone with basic knowledge with CSS (cascading style sheets) can customize their Waybar layouts. There is no specialized training and learning required. With CSS, you can adjust font, color, and the layout.
  3. Multi-output compatible: Waybar is pre-configured to handle multiple monitor setups. This allows different configurations at each display output.
  4. Scripts and hooks: You can add your scripts to have your own modules or modify existing modules to insert custom functionalities. You can use hooks to trigger actions based on system events like CPU usage spike.
  5. Robust yet lightweight: With all these features and flexibility, Waybar is still lightweight and does not consume excessive CPU, memory, and disk space.

How to Install Waybar

On most of the Linux flavors and distributions, Waybar is available in the package manager. If you prefer installing it, here are the steps.

For Debian, Ubuntu, and other distros:

sudo apt install waybar

For Arch Linux:

sudo pacman -S waybar

How to Configure

The basic configuration is done through JSON files. Here is a basic example of Waybar JSON file:

{<br />"layer": "top",<br />"modules-left": ["sway/workspaces", "sway/mode"],<br />"modules-center": ["sway/window"],<br />"modules-right": ["battery", "clock"],<br />"sway/window": {<br />"max-length": 50<br />},<br />"battery": {<br />"format": "{capacity}% {icon}",<br />"format-icons": ["", "", "", "", ""]<br />},<br />"clock": {<br />"format-alt": "{:%a, %d. %b %H:%M}"<br />}<br />}

This configuration positions the battery and clock modules on the right, window title in the center, and the workspaces and mode modules on the left.

How to Add Custom Modules

Custom modules can be added by defining in the configuration JSON file. Here is an example JSON configuration file to add a weather module:

"custom/weather": {<br />"exec": "curl -s 'wttr.in?format=3'",<br />"interval": 1800,<br />"format": "{}"<br />}

How to Customize the Style

Waybar’s style can be customized by using the style.css file. Let us take a look at an example CSS file to customize the clock and battery modules.

#clock {<br />font-size: 16px;<br />color: #ffffff;<br />}<br />#battery {<br />font-size: 14px;<br />color: #ff0000;<br />}

Once this CSS file is referenced in Waybar configuration, the style changes will be applied. To reference this CSS file, append the JSON file with the code below:

"css": "/path/to/style.css"

How to Use Multiple Monitors

You can define distinct configurations for each monitor or display output. For example, if there are two monitors connected via HDMI ports, configuration files can be referenced to each output.

{<br />"output": "HDMI-1",<br />"config": "/path/to/hdmi1.json"<br />},<br />{<br />"output": "eDP-1",<br />"config": "/path/to/edp1.json"<br />}

Wrapping Up

Waybar is a very useful tool for anyone using Sway or any compatible Window manager. It has powerful in-built modules and also the option to add and customize new and existing modules as well. With this guide, you can build and customize your own modules with minimal effort.

Related Links

Git link of Waybar

Some More Articles that would be of Interest to You