This bar project aims to create a highly flexible, customizable, fast and powerful status bar replacement for users that like playing around with
shell scripts.
![](images/example.png)
More example setups here.
Table of Contents
=================
* [Table of Contents](#table-of-contents)
* [Features](#features)
* [Installation](#installation)
* [Stable Version](#stable-version)
* [Plugins and Fonts](#plugins-and-fonts)
* [Global configuration of the bar](#global-configuration-of-the-bar)
* [Items and their properties](#items-and-their-properties)
* [Adding items to sketchybar](#adding-items-to-sketchybar)
* [Changing item properties](#changing-item-properties)
* [Changing the default values for all further items](#changing-the-default-values-for-all-further-items)
* [Components -- Special Items with special properties](#components----special-items-with-special-properties)
* [Data Graph -- Draws an arbitrary graph into the bar](#data-graph----draws-an-arbitrary-graph-into-the-bar)
* [Space -- Associate mission control spaces with an item](#space----associate-mission-control-spaces-with-an-item)
* [Item Bracket -- Group Items in e.g. colored sections](#item-bracket----group-items-in-eg-colored-sections)
* [Item Alias -- Mirror items of the original macOS status bar into sketchybar](#item-alias----mirror-items-of-the-original-macos-status-bar-into-sketchybar)
* [Popup Menus](#popup-menus)
* [Batching of configuration commands](#batching-of-configuration-commands)
* [Events and Scripting](#events-and-scripting)
* [Creating custom events](#creating-custom-events)
* [Triggering custom events](#triggering-custom-events)
* [Forcing all shell scripts to run and the bar to refresh](#forcing-all-shell-scripts-to-run-and-the-bar-to-refresh)
* [Querying](#querying)
* [Bar Properties](#bar-properties)
* [Item Properties](#item-properties)
* [Default Properties](#default-properties)
* [Event Properties](#event-properties)
* [Item Reordering](#item-reordering)
* [Moving Items to specific positions](#moving-items-to-specific-positions)
* [Item Cloning](#item-cloning)
* [Renaming Items](#renaming-items)
* [Removing Items](#removing-items)
* [Performance optimizations](#performance-optimizations)
* [Credits](#credits)
## Features
* Performance friendly
* No accessibility permissions needed
* Fully scriptable
* Highly configurable
* Supports drawing native macOS menu bar applications
* Powerful event system (items can subscribe to many system events)
* Popup Menus
* Mouse Support
* Many visual features
* Support for graphs
* Per display and per space individualization
The configuration of the bar takes place in a confiuration file where almost everything can be configured.
Basically, the bar itself is a rectangle that can hold arbitrarily many *items*, which can be configured to do awesome stuff.
An *item* will occupy a space in the bar and can be equipped to show an *icon* and a *label*. The *icon* and *label* can be changed through
*scripts* that can be attached to the *item*. It is also possible to *subscribe* an *item* to certain *events* for their *script* execution action,
which makes very powerful items possible.
Furthermore, an *item* can be assigned to mission control spaces or displays, such that they only show on a certain space or display, which makes multi-desktop configuration
of the bar possible and opens the possibility to create individualized bar configuration on a per display and per space level.
These simple ingredients make *items* almost endlessly customizable and can be used to display arbitrary information and perform useful actions. For some examples see my sketchybarrc and
the plugins folder.
Some special features can not be accomplished with a simple *item*, this is where the *components* come into play. They basically are *items* with
extra steps. They contain all the properties a regular item does, but they can do specialized tasks a simple item can not. For example, there
is a *graph* component, which can be used to display graphs in the bar.
For more details on how the configuration works, see the configuration section below.
## Installation
### Stable Version
```bash
brew tap FelixKratz/formulae
brew install sketchybar
```
Do not forget to copy the example configuration files to your home directory (the brew installation specific commands are listed in the caveats section after the brew install is finished).
Run the bar via
```bash
brew services start sketchybar
```
### Plugins and Fonts
When you use additional plugins, make sure that they are referenced in the rc with the correct path and that they are made executable via
```bash
chmod +x name/of/plugin.sh
```
The default plugin folder is located in `~/.config/sketchybar/plugins`.
All plugins must work with absolute paths because relative paths will not be resolved correctly.
Have a look at the [discussion](https://github.com/FelixKratz/SketchyBar/discussions/12) about plugins and share your own if you want to.
You should of course vet the code from all plugins before executing them to make sure they are not harming your computer.
If you have problems with missing fonts you might need to install the Hack Nerd Font:
```bash
brew tap homebrew/cask-fonts
brew install --cask font-hack-nerd-font
```
## Global configuration of the bar
For an example configuration see the supplied default *sketchybarrc*. The configuration file resides in `~/.config/sketchybar/`, where everything can be freely configured. It is also possible to play around with properties in a terminal and change them while the bar is running, once you find a fitting value you can include it in the `sketchybarrc` file such that the configuration is restored on restart. The global bar properties can be configured by invoking:
```bash
sketchybar --bar = ... =
```
where possible settings are:
| \ | \ | default | description |
| :-------: | :------: | :-------: | ----------- |
| `color` | `` | `0x44000000` | Color of the bar |
| `border_color` | `` | `0xffff0000` | Color of the bars border |
| `position` | `top`, `bottom` | `top` | Position of the bar on the screen |
| `height` | `` | `25` | Height of the bar |
| `margin` | `` | `0` | Margin around the bar |
| `y_offset` | `` | `0` | Vertical offset of the bar from its default position |
| `corner_radius` | `` | `0` | Corner radius of the bar |
| `border_width` | `` | `0` | Border width of the bars border |
| `blur_radius` | `` | `0` | Blur radius applied to the background of the bar |
| `padding_left` | `` | `0` | Padding between the left bar border and the leftmost item |
| `padding_right` | `` | `0` | Padding between the right bar border and the rightmost item |
| `display` | `main`, `all` | `all` | Display to show the bar on |
| `hidden` | `` | `off` | If the bar is hidden |
| `topmost` | `` | `off` | If the bar should be drawn on top of `everything` |
| `font_smoothing` | `` | `off` | If fonts should be smoothened |
| `shadow` | `` | `off` | If the bar should draw a shadow |
## Items and their properties
Items are the main building blocks of sketchybar and can be configured in a number of ways. Items have the following basic structure:
### Adding items to sketchybar
```bash
sketchybar --add item
```
where the `` should not contain whitespaces (or must be quoted), it can be used to further configure the item.
The `` is the placement in the bar and can be either *left*, *right* or *center*. The items will appear in the bar in the order
in which they are added, but can be moved later on.
| `` | `` |
| ----- | --------- |
| `` | `left`, `right`, `center`, (`q`, `e` [#120](https://github.com/FelixKratz/SketchyBar/issues/120)) |
### Changing item properties
```bash
sketchybar --set = ... =
```
where the *name* is used to target the item with this name.
(The *name* can be a regular expression inside of two '/': */\/*)
A list of properties available to the *set* command is listed below (components might have additional properties, see the respective component section for them):
* Geometry Properties:
| \ | \ | default | description |
| :-------: | :------: | :-------: | ----------- |
| `position` | `left`, `right`, `center` | | Position of the item in the bar |
| `associated_space` | `` | `0` | Spaces to show this item on |
| `associated_display` | `` | `0` | Displays to show this item on |
| `y_offset` | `` | `0` | Vertical offset applied to the `text` |
| `width` | `` or `dynamic` | `dynamic` | Makes the *item* use a fixed *width* given in points |
| `align` | `center`, `left`, `right` | `left` | Aligns the `item` content in its container when it has a fixed `width` larger than the content width |
* Drawing properties:
| \ | \ | default | description |
| :-------: | :------: | :-------: | ----------- |
| `drawing` | `` | `on` | If the item should be drawn into the bar |
| `lazy` | `` | `off` | Changes do not trigger a redraw of the bar, item is refreshed when the bar is redrawn anyways |
* Icon properties:
| \ | \ | default | description |
| :-------: | :------: | :-------: | ----------- |
| `icon` | `` | | Icon of the item |
| `icon.` | | | Icons support all *text* properties |
* Label properties:
| \ | \ | default | description |
| :-------: | :------: | :-------: | ----------- |
| `label` | `` | | Label of the item |
| `label.` | | | Labels support all *text* properties |
* Scripting properties:
| \ | \ | default | description |
| :-------: | :------: | :-------: | ----------- |
| `script` | ``, `` | | Script to run on an `event` |
| `click_script` | ``, `` | | Script to run on a mouse click (Difference to `mouse.clicked` event: [#109](https://github.com/FelixKratz/SketchyBar/discussions/109)) |
| `update_freq` | `` | `1` | Time in seconds between routine script executions |
| `updates` | ``, `when_shown` | `on` | If and when the item updates e.g. via script execution |
* Text properties:
| \ | \ | default | description |
| :-------: | :------: | :-------: | ----------- |
| `drawing` | `` | `on` | If the text is rendered |
| `highlight` | `` | `off` | If the text uses the `highlight_color` or the regular `color` |
| `color` | `` | `0xffffffff` | Color used to render the text |
| `highlight_color` | `` | `0xff000000` | Highlight color of the text (e.g. for active space icon |
| `padding_left` | `` | `0` | Padding to the left of the `text` |
| `padding_right` | `` | `0` | Padding to the right of the `text` |
| `y_offset` | `` | `0` | Vertical offset applied to the `text` |
| `width` | `` or `dynamic` | `dynamic` | Makes the `text` use a fixed `width` given in points |
| `align` | `center`, `left`, `right` | `left` | Aligns the `text` in its container when it has a fixed `width` larger than the content width |
| `background.` | | | Texts support all `background` properties |
| `shadow.` | | | Texts support all `shadow` properties |
* Background properties:
| \ | \ | default | description |
| :-------: | :------: | :-------: | ----------- |
| `drawing` | `` | `off` | If the `background` should be rendered |
| `color` | `` | `0x00000000` | Fill color of the `background` |
| `border_color` | `` | `0x00000000` | Color of the backgrounds border |
| `border_width` | `` | `0` | Width of the background border |
| `height` | `` | `0` | Overrides the `height` of the background |
| `corner_radius` | `` | `0` | Corner radius of the background |
| `padding_left` | `` | `0` | Padding to the left of the `background` |
| `padding_right` | `` | `0` | Padding to the right of the `background` |
| `y_offset` | `` | `0` | Vertical offset applied to the `background` |
| `image` | `` | | The path to a png or jpeg image file |
| `image.` | | | Backgrounds support all `image` properties |
| `shadow.` | | | Backgrounds support all `shadow` properties |
* Image properties (Can be resource intensive if many large images are drawn):
| \ | \ | default | description |
| :-------: | :------: | :-------: | ----------- |
| `drawing` | `` | `off` | If the image should draw |
| `scale` | `` | `0` | The scale factor that should be applied to the image |
* Shadow properties:
| \ | \ | default | description |
| :-------: | :------: | :-------: | ----------- |
| `drawing` | `` | `off` | If the shadow should be drawn |
| `color` | `` | `0xff000000` | Color of the shadow |
| `angle` | `` | `30` | Angle of the shadow |
| `distance` | `` | `5` | Distance of the shadow |
### Changing the default values for all further items
It is possible to change the *defaults* at every point in the configuration. All item created *after* changing the defaults will
inherit these properties from the default item.
```bash
sketchybar --default = ... =
```
this works for all item properties.
### Type nomenclature
| `type` | `values` |
| ----- | --------- |
| `` | `on`, `off`, `yes`, `no`, `true`, `false`, `1`, `0`, `toggle` |
| `` | Color as an 8 digit hex with alpha, red, green and blue channels |
| `` | An absolute file path |
| `` | Any UTF-8 string or symbol |
| `` | A floating point number |
| `` | An integer |
| `` | A positive integer |
| `` | A comma separated list of positive integers |
## Components -- Special Items with special properties
Components are essentially items, but with special properties.
Currently there are the components (more details in the corresponding sections below):
* *graph*: showing a graph,
* *space*: representing a mission control space
* *bracket*: brackets together other items
* *alias*: a default menu bar item
### Data Graph -- Draws an arbitrary graph into the bar
```bash
sketchybar --add graph
```
Additional graph properties:
* *graph.color*: color of the associated graph
* *graph.fill_color*: optional property to override the automatically calculated fill color of the graph
* *graph.line_width*: sets the line width of the associated graph
| \ | \ | default | description |
| :-------: | :------: | :-------: | ----------- |
| `graph.color` | `` | `0xcccccc` | Color of the graph line |
| `graph.fill_color` | `` | `0xcccccc` | Fill color of the graph |
| `graph.line_width` | `` | `0.5` | Width of the line in points |
Push data points into the graph via:
```bash
sketchybar --push
```
### Space -- Associate mission control spaces with an item
```bash
sketchybar --add space
```
The space component overrides the definition of the following properties and they must be set to correctly associate a mission control space with this item:
* *associated_space*: Which space this item represents
* *associated_display*: On which display the *associated_space* is shown.
The space component has additional variables available in *scripts*:
```bash
$SELECTED
$SID
$DID
```
where *$SELECTED* has the value *true* if the associated space is selected and *false* if the selected space is not selected, while
`$SID` holds the space id and `$DID` the display id.
By default the space component invokes the following script:
```bash
sketchybar --set $NAME icon.highlight=$SELECTED
```
which you can freely configure to your liking by supplying a different script to the space component:
```bash
sketchybar --set script=