Skip to content

Adding support for dynamic actions #302

@A-Helberg

Description

@A-Helberg

Dynamic Actions

It would be great if Leader Key could support dynamically generated groups that execute scripts to populate their contents at runtime.

Why?

Dynamic actions would allow Leader Key to integrate with any application/system that has an API and respond to that system.

I have made a proof of concept (vibe coded) for myself locally and have used this to dynamically control aerospace. leader-key + s shows active aerospace sessions, with the first letter of the space name as the next key to switch to it.

The menu would automatically be update when sessions are killed or created the next time the menu is shown.

Image

Usage

{
  "type": "group",
  "actions": [
    {
      "key": "d",
      "type": "dynamic",
      "label": "Dynamic Items",
      "value": "/path/to/your/script.sh"
    }
  ]
}

Script Requirements

A script must output a JSON array of actions/groups to stdout:

[
  { "key": "a", "type": "application", "value": "/Applications/Safari.app" },
  { "key": "b", "type": "url", "value": "https://example.com" }
]

Considerations

  1. While the script is executing a loading spinner is displayed in the Leader Key window.
  2. Normally the cheatsheet is hidden, for dynamic items, it would be useful to show as soon as the script completes.
  3. Normally key strokes are executed immediately, for dynamic groups they would need to be queued and executed as the script(s) complete.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions