Coder Social home page Coder Social logo

yabai-spaces's Introduction

Yabai Spaces

A swiftbar plugin displays yabai spaces, inspired by SxC97/Yabai-Spaces.

Features

image

  • Display yabai spaces in Mac OS menu bar.
    • Separate spaces belonging to different monitors (two monitors in the above image, and spaces of them are separated by '>')
    • Highlight current space for each monitor and markup focused space (displayed spaces are in red, focused space is wrapped by '<<' '>>')
    • Show up yabai spaces' labels, and you can easily customize them in a simple script

Requirements

Installation & Usage

Yabai Spaces in menu bar

Copy yabai.1d.py to your SwiftBar/xbar plugin's directory. If SwiftBar is running, you may see Yabai Spaces in your menu bar.

If SwiftBar is running and you cannot see it, it might be there is no enough space to display Yabai Spaces.

You'd better press Command key and at the same time drag Yabai Spaces menu bar item to the most right to try to avoid it being hidden when there are plenty of menu bar tray icons and no space left to display Yabai Spaces.

Add these to your .yabairc to rerender Yabai Spaces after some yabai events to ensure it presents the latest status of spaces:

# update yabai-spaces in status bar
yabai -m signal --add event=space_changed action="open -gj 'swiftbar://refreshplugin?name=yabai'"
yabai -m signal --add event=window_focused action="open -gj 'swiftbar://refreshplugin?name=yabai'"
yabai -m signal --add event=display_added action="open -gj 'swiftbar://refreshplugin?name=yabai'"
yabai -m signal --add event=display_removed action="open -gj 'swiftbar://refreshplugin?name=yabai'"
yabai -m signal --add event=display_changed action="open -gj 'swiftbar://refreshplugin?name=yabai'"
yabai -m signal --add event=display_moved action="open -gj 'swiftbar://refreshplugin?name=yabai'"

You can customize yabai.1d.py script as you need.

For example, change the font by set CUSTOM_FONT variable. If you want to customize how the space is displayed, you can edit get_space_display_string function.

Persist Yabai Space Labels

When you restart Yabai, all the labels of spaces will be reset. And here comes the scripts to persist these data.

Executing rename-space.fish (bind this script to a hotkey in skhd is recommended) will prompt choose to rename current focused space's label and persist latest labels to a local csv file $HOME/.yabai-labels.csv which contains (space index, label) pairs.

One more step is to load these space labels on the startup of yabai: add restore-space-labels.fish to your .yabairc configuration like this

# restore space labels
/path/to/yabai-spaces/restore-space-labels.fish

About rename space label

image

In choose, you get a default '»' in the selection list. This selection item represents clearing the space label. Press Enter to choose a selection item in choose.

Type any new label you want in choose and press Enter, and you'll get your space label renamed.

If you want to cancel renaming space in choose, use Esc.

Display skhd mode

Since skhd command-line does not provide methods to get current skhd mode, we need to store it to somewhere which I choose a temp file /tmp/skhd_mode.

Executing skhd-mode.py with no arguments will print currently saved skhd mode. Execute it with arguments to save the argument string as new skhd mode. You can put this script in your shell PATH.

What's more, in skhd config, skhd-mode.py with mode name as argument should be executed when skhd enters a mode.

For example, when entering default mode, execute skhd-mode.py(assuming it's in shell PATH) with mode name and then refresh yabai swiftbar plugin.

:: default : skhd-mode.py default; open -gj 'swiftbar://refreshplugin?name=yabai'

yabai.1d.py uses this script to get current skhd mode and displays it.

image

If skhd-mode.py is not in your shell PATH, you should not only change the script path in skhd config above, but also set the variable YABAI_SPACES_PATH in yabai.1d.py.

Changelog

  • v0.1
    • Add skhd mode display and related scripts
    • Replace Fish shell scripts with Python scripts
    • Update requirements and add some screenshots in README

yabai-spaces's People

Contributors

gkzhb avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.