Xbar and SwiftBar plugin

The Meta Package Manager project is actively maintaining a plugin that is both compatible with Xbar and SwiftBar.

The plugin is written in Python and is a small wrapper around the mpm CLI.

Hint

I recommend SwiftBar, because Xbar has 2 outstanding issues:

Configuration

The plugin is configurable with these environment variables:

Variable name

Description

Type

Defaults

SwiftBar support

Xbar support

VAR_SUBMENU_LAYOUT

Group packages into a sub-menu for each manager.

Boolean

False

VAR_TABLE_RENDERING

Aligns package names and versions in a table for easier visual parsing.

Boolean

True

VAR_DEFAULT_FONT

Default font to use for non-monospaced text.

String

Empty

❌*

VAR_MONOSPACE_FONT

Default configuration for monospace fonts, including errors. Is used for table rendering.

String

font=Menlo size=12

❌*

Screenshots

SwiftBar

VAR_SUBMENU_LAYOUT = False
VAR_TABLE_RENDERING = False
assets/swiftbar-flatmenu-standard-rendering.png
VAR_SUBMENU_LAYOUT = False
VAR_TABLE_RENDERING = True
(default)
assets/swiftbar-flatmenu-table-rendering.png
VAR_SUBMENU_LAYOUT = True
VAR_TABLE_RENDERING = True
assets/swiftbar-submenu-table-rendering.png
VAR_SUBMENU_LAYOUT = True
VAR_TABLE_RENDERING = False
assets/swiftbar-submenu-strandard-rendering.png

Xbar

VAR_SUBMENU_LAYOUT = False
VAR_TABLE_RENDERING = False
assets/xbar-flatmenu-standard-rendering.png
VAR_SUBMENU_LAYOUT = False
VAR_TABLE_RENDERING = True
(default)
assets/xbar-flatmenu-table-rendering.png
VAR_SUBMENU_LAYOUT = True
VAR_TABLE_RENDERING = True
assets/xbar-submenu-table-rendering.png
VAR_SUBMENU_LAYOUT = True
VAR_TABLE_RENDERING = False
assets/xbar-submenu-strandard-rendering.png

Location

A copy of the latest stable version of the plugin is available on Xbar website and plugin repository.

Once mpm is installed on your system, it can dynamiccaly be located with the dedicated --xbar-plugin-path option:

$ mpm --bar-plugin-path
~/Library/Python/3.10/lib/python/site-packages/meta_package_manager/bar_plugin.py

This option is handy for deployment and initial configuration of Xbar/SwiftBar. I personally use this in my dotfiles to symlink the plugin to its latest version:

$ ln -sf "$(mpm --bar-plugin-path)" "${HOME}/Library/Application Support/xbar/plugins/mpm.7h.py"

Python >=3.8 required

Xbar plugins are self-contained scripts. As such, it needs to be able to run without any extra dependency, on the pre-installed Python distribution that ships with macOS.

With Python 3.7 being EOL and not receiving any security updates as of 2023-06-27, the plugin requires Python 3.8 or newer.

For reference:

Development workflow

Active development of the plugin is happening here, as a side-project of mpm itself.

Releases of the plugin is synchronized with the package. Both share the exact same version to simplify management. This explain why the plugin could appears jumping ahead a couple of major/minor versions while providing tiny or no changes at all.

A release is ready when both the package and the plugin reach a stable state.

If the plugin has been changed between releases, a copy of the plugin is pushed under the name meta_package_manager.7h.py, to the official Xbar plugin repository.

Release process

  1. Fork the official Xbar plugin repository.

  2. Fetch a local copy of the fork:

    $ git clone https://github.com/kdeldycke/xbar-plugins
    $ cd xbar-plugins
    
  3. Create a new branch and switch to it:

    $ git branch "meta-package-manager-v4.13.1"
    $ git checkout "meta-package-manager-v4.13.1"
    
  4. Replace existing copy of the plugin with the latest tagged version:

    $ wget https://raw.githubusercontent.com/kdeldycke/meta-package-manager/v4.13.1/meta_package_manager/bar_plugin.py
    $ mv ./bar_plugin.py ./Dev/meta_package_manager.7h.py
    $ chmod 755 ./Dev/meta_package_manager.7h.py
    
  5. Commit the new plugin:

    $ git add ./Dev/meta_package_manager.7h.py
    $ git commit -m "Upgrade to Meta Package Manager plugin v4.13.1"
    
  6. Push new branch:

    $ git push --set-upstream origin "meta-package-manager-v4.13.1"
    
  7. Create a pull-request in the original repository.