Skip to main content


Write xbar app plugins using TypeScript/JavaScript and Deno
Go to Latest

Deno xbar

Write xbar app plugins using JavaScript and Deno



Deno is a simple, modern and secure runtime for JavaScript and TypeScript that uses V8 and is built in Rust.

Shell (Mac, Linux):

curl -fsSL | sh

Homebrew (Mac):

brew install deno

See deno_install and releases for other options.


xbar lets you put the output from any script/program in your macOS menu bar.

Download the latest release of xbar.


In the xbar plugins directory create a file named with the following format:


On the first line of that file include a shebang in the following format:

#!/usr/bin/env /path/to/the/deno/executable run <permissions>

This module can be imported to the plugin with the following code:

import { xbar, separator, isDarkMode } from "";

Deno is secure by default. Therefore, unless you specifically enable it, a program run with Deno has no file, network, or environment access. Replace <permissions> with the permissions required for the plugin. See Deno Manual for more.

Ensure that the file is executable by using the command chmod +x filename.js. Read more.


#!/usr/bin/env /path/to/the/deno/executable run --allow-env

import { xbar, separator, isDarkMode } from "";

const darkMode = await isDarkMode(); 

        text: 'plugin text on the menu bar',
        color: darkMode ? 'white' : 'red',
        text: 'plugin text below the menu bar',
        color: '#85b56d',
        submenu: [
                text: 'plugin text in a submenu menu that is long and is word wrapped',
                wordWrap: 40

See examples for more.



Prints output to xbar and returns printed output as an array of strings

Type: (Array<MenuItem>) => string[]

Takes an array of MenuItem objects, that represent xbar menu items, as input.

Type: object

MenuItem can contain any of the following fields:

  text: string;
  submenu: Array<MenuItem>;

Type: Array<MenuItem>

It will add a submenu to the current menu item. A submenu is composed of an array of menu items. Submenus can contain nested submenus.


Type: option: any

You can use any of the xbar supported options. Additionally this module enables an additional wordWrap option.


Enabling the wordWrap option will result in the improved readability of long text by outputting the text as multiple lines with out breaking any apart words.


  text: 'Douglas Crockford',
  submenu: [
      text: 'In JavaScript, there is a beautiful, elegant, highly expressive language that is buried under a steaming pile of good intentions and blunders.',
      wordWrap: 40,

' '


The menu items below separator will appear in the plugin’s drop down, but will not appear in the menu bar itself.


Async function to query if dark mode is enabled.

Type: async () => Promise<boolean>

Will always return false if environment permission has not previously been granted --allow-env

#!/usr/bin/env deno run --allow-env
import { isDarkMode } from "";

const darkMode = await isDarkMode();