ArchWiki / Polybar
ArchWiki / Polybar
fi:Polybar ja:Polybar pl:Polybar pt:Polybar ru:Polybar zh-hans:Polybar 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
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:
[bar/mybar]
modules-right = date
[module/date]
type = internal/date
date = %Y-%m-%d%config.iniIt 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 &
fiThen configure Polybar to read the monitor from the environment:
[bar/example]
monitor = ${env:MONITOR:}
[..]config.iniTroubleshooting
ThinkPad battery display
On Lenovo ThinkPad X200 and related models, the battery level display frequently stops after having resumed from system suspension (such as re-opening the lid), due to a weird firmware on the models.https://github.com/polybar/polybar/issues/1937 Restarting polybar allows it to pick up on the battery again. This can be automated by a systemd unit that runs polybar-msg cmd restart when resuming from suspension.
Ensure polybar is configured to use polybar-msg:
[bar/example]
enable-ipc = trueconfig.iniWith additional configuration a similar unit can be installed in .config/systemd/, which makes it possible to manage with other dotfiles
[Unit]
Description=Restart polybar after suspend
After=suspend.target hibernate.target
[Service]
Type=exec
ExecStart=/usr/bin/systemd-run --machine=%i@ --user polybar-msg cmd restart
[Install]
WantedBy=suspend.target hibernate.target/etc/systemd/system/polybar-resume@.serviceEnable the polybar-resume@user.service unit.