Polybar: Difference between revisions

From ArchWiki
m (Remove extra white space)
m (fixed minor inconsistency in config filename)
 
(6 intermediate revisions by 5 users not shown)
Line 14: Line 14:
== Configuration ==
== Configuration ==


Copy the configuration example from {{ic|/etc/polybar/config.ini}} to {{ic|$XDG_CONFIG_HOME/polybar/config}}. By default, polybar will load the config file from {{ic|~/.config/polybar/config.ini}}, {{ic|/etc/xdg/polybar/config.ini}}, or {{ic|/etc/polybar/config.ini}} depending on which it finds first.
Copy the configuration example from {{ic|/etc/polybar/config.ini}} to {{ic|$XDG_CONFIG_HOME/polybar/config.ini}}. By default, polybar will load the config file from {{ic|~/.config/polybar/config.ini}}, {{ic|/etc/xdg/polybar/config.ini}}, or {{ic|/etc/polybar/config.ini}} depending on which it finds first.


=== Running Polybar ===
=== Running Polybar ===


Polybar can be run with the following arguments:
See {{ic|polybar --help}} for a list of options to run it manually. However, you will probably want to run Polybar with your window manager's bootstrap routine. See [[#Running with a window manager]].
 
{{bc|1=
Usage: polybar [OPTION]... [BAR]
 
  -h, --help                   Display this help and exit
  -v, --version                Display build details and exit
  -l, --log=LEVEL              Set the logging verbosity (default: notice)
                              LEVEL is one of: error, warning, notice, info, trace
  -q, --quiet                  Be quiet (will override -l)
  -c, --config=FILE            Path to the configuration file
  -r, --reload                Reload when the configuration has been modified
  -d, --dump=PARAM            Print value of PARAM in bar section and exit
  -m, --list-monitors          Print list of available monitors and exit (Removes cloned monitors)
  -M, --list-all-monitors      Print list of all available monitors (Including cloned monitors) and exit
  -w, --print-wmname          Print the generated WM_NAME and exit
  -s, --stdout                Output data to stdout instead of drawing it to the X window
  -p, --png=FILE              Save png snapshot to FILE after running for 3 seconds
}}
 
However you will probably want to run Polybar with your window manager's bootstrap routine. See [[#Running with a window manager]].


=== Sample configuration ===
=== Sample configuration ===
Line 44: Line 24:
A very basic polybar configuration may look like this:
A very basic polybar configuration may look like this:


{{bc|1=
{{hc|config.ini|2=
[bar/mybar]
[bar/mybar]
modules-right = date
modules-right = date
Line 77: Line 57:
This script will mean that restarting your window manager will also restart Polybar.
This script will mean that restarting your window manager will also restart Polybar.


==== bspwm ====
To execute this script by your window manager on startup, see [[Autostarting#On window manager startup]].
 
=== Multiple monitors ===


If using [[bspwm]], add the following to {{ic|bspwmrc}}:
If you wish to have your bar duplicated across multiple monitors, you need to launch multiple bars.


Add something like this to your startup script:
{{bc|
{{bc|
$HOME/.config/polybar/launch.sh
if type "xrandr"; then
  for m in $(xrandr --query {{!}} grep " connected" {{!}} cut -d" " -f1); do
    MONITOR{{=}}$m polybar --reload example &
  done
else
  polybar --reload example &
fi
}}
}}


==== i3 ====
Then configure Polybar to read the monitor from the environment:
 
{{hc|config.ini|2=
If using [[i3]], add the following to your i3 configuration:
[bar/example]
 
monitor = ${env:MONITOR:}
{{bc|
[..]
exec_always --no-startup-id $HOME/.config/polybar/launch.sh
}}
}}



Latest revision as of 20:32, 4 December 2023

polybar is a fast and easy-to-use tool for creating status bars. It aims to be easily customizable, utilising many modules which enable a wide range of (editable) functionality, such as displaying workspaces, the date, or system volume. Polybar is especially useful for window managers that have a limited or non-existent status bar, such as awesome or i3. Polybar can also be used with desktop environments like Plasma.

Installation

Install the polybar package. The development version is polybar-gitAUR.

Configuration

Copy the configuration example from /etc/polybar/config.ini to $XDG_CONFIG_HOME/polybar/config.ini. By default, polybar will load the config file from ~/.config/polybar/config.ini, /etc/xdg/polybar/config.ini, or /etc/polybar/config.ini depending on which it finds first.

Running Polybar

See polybar --help for a list of options to run it manually. However, you will probably want to run Polybar with your window manager's bootstrap routine. See #Running with a window manager.

Sample configuration

A very basic polybar configuration may look like this:

config.ini
[bar/mybar]
modules-right = date

[module/date]
type = internal/date
date = %Y-%m-%d%

It defines a bar named mybar with a module called date.

Polybar will also install the default configuration with many preconfigured modules in /etc/polybar/config.ini.

Running with a window manager

Create an executable file containing the startup logic, for example $HOME/.config/polybar/launch.sh:

#!/bin/bash

# Terminate already running bar instances
killall -q polybar
# If all your bars have ipc enabled, you can also use
# polybar-msg cmd quit

# Launch Polybar, using default config location ~/.config/polybar/config.ini
polybar mybar 2>&1 | tee -a /tmp/polybar.log & disown

echo "Polybar launched..."

This script will mean that restarting your window manager will also restart Polybar.

To execute this script by your window manager on startup, see Autostarting#On window manager startup.

Multiple monitors

If you wish to have your bar duplicated across multiple monitors, you need to launch multiple bars.

Add something like this to your startup script:

if type "xrandr"; then
  for m in $(xrandr --query | grep " connected" | cut -d" " -f1); do
    MONITOR=$m polybar --reload example &
  done
else
  polybar --reload example &
fi

Then configure Polybar to read the monitor from the environment:

config.ini
[bar/example]
monitor = ${env:MONITOR:}
[..]

See also