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

Font parameters for regular text.

String

Empty

❌*

VAR_MONOSPACE_FONT

Font parameters for monospace text. Used for table rendering and error messages.

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.11/lib/python/site-packages/meta_package_manager/bar_plugin.py

This option is handy for deployment and initial configuration of Xbar/SwiftBar. I 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.9 required

The plugin requires Python 3.9 or newer. Which is the version that ships with the latest macOS releases:

macOS version

Python version[^1]

16.x - TBA

3.9.6

15.x - Sequoia

3.9.6

14.x - Sonoma

3.9.6

13.x - Ventura

3.8.9

That way, the plugin is compatible with the latest macOS releases out of the box, and can be run as-is without any extra dependency.

Caution

It looks like since Monterey (macOS), there is no default Python version installed anymore, and the python CLI is a stub that points to the App Store to install Xcode:

$ python3 --version
xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Choose an option in the dialog to download the command line developer tools.

[^1] Source: https://ihaveahax.net/wiki/Python_version_information#Xcode_(macOS)

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.