A bunch of scripts able to create a "dynamic traybar" experience for Polybar in i3wm, making it behave kinda like a module.
- A recent version of Polybar;
- i3wm (rather v.4.17+);
- Install scripts, hooks and module.
- Download the latest release and extract to a folder or clone this repository with
git clone https://github.com/daltroaugusto/polybar-dynamic-trayoffset.git
, then browse to the working folder; - Run
sudo ./install
(installation script with root privileges), or just copy the scripts to a folder in your$PATH
; - Insert the
polybar_trayoffset
module at the position you prefer, in Polybar config file:
|
- Make sure to also set up properly the traybar's offset. The tray must be positioned in a way that overlays the module.
Notice how the tray is out of position. The module is positioned to the right of the clock. We need to correct this setting up in a way that tray stay exactly where the module will do their work (in this case, more to the right of the clock), by using the parameters tray-offset-x
and tray-position
:
- Now that the module is exactly in the position where tray is invoked by Polybar, we must, manually, set up hooks for every program that would use the tray. Let's say that
qbittorrent
(a Qt-based torrent client) wants to use some space in our traybar. Then we'd need to add the following statement in our i3wm's config file:
for_window [class="qbittorrent"] exec watchps_tray qbittorrent
This command will make that, for each time a window of such that application's class is detected (that will also occupies space in tray), will also be started an instance of watchps_tray
that keeps needed space in the module previously setted up, what will give you a kinda dynamic traybar experience, just as follows:
- By setting up the fonts in Polybar, it is possible to define, with
format-prefix
andformat-suffix
, a monospaced font for the module (like Consolas), which would make the added largure for each application as fixed as any character of that font (regardless any other font in the bar). This is a not recommended option, personally. - By inserting an integer and positive number aside the application's name in
watchps_tray <application>
, it is possible to manually set up the spacing size created in tray. - Just for exceptional situations, the command
polybar_trayoffset remove-all
can be globally executed, and any spacement added within the module will be immediately removed.
- Centralize the management of apps that use the tray within the
polybar_trayoffset
script. - Find some tool or mechanism similar to what wmctrl is for windows, but for tray elements, what would make possible a more automatic flow/behavior.