swiftbar / SwiftBar

Powerful macOS menu bar customization tool
https://swiftbar.app
MIT License
2.87k stars 91 forks source link

Shortcuts Plugins #344

Closed melonamin closed 8 months ago

melonamin commented 1 year ago

Shortcuts Plugins

Currently to create a plugin the user must have basic scripting\coding skills. Implementing a new type of plugin - “Shortcut Plugin” - would allow users to create the plugins inside Shortcuts app, potentially expanding the user base.

TODO:

BETA

Shortcut Examples

Adding Shortcuts Plugin Settings View:

CleanShot 2022-11-08 at 16 01 34@2x CleanShot 2022-11-08 at 16 01 51@2x
dchevell commented 1 year ago

When I click "Add" under macOS Ventura (SwiftBar: 1.5.0 (478), macOS: 13.1 (22C65)) nothing appears and SwiftBar beachballs until I have to force quit.

Just curious - is that expected, or can I provide any useful diagnostic data? Not bothered, but happy to test/troubleshoot if it's helpful.

Edit: I saw there's a build 479 - retested just in case & saw the same issue. For whatever reason checking "Include pre-release…" and clicking "Check for updates" got me from 1.4.4 to 1.5.0 b478, but it doesn't seem to see b479, so I downloaded manually to test.

melonamin commented 1 year ago

Hi @dchevell,

sorry, for some reason I missed the notification about your comment from GitHub... :(

Can you please try this build? If you see the beach ball, can you get the logs from Console.app (Search = "process == SwiftBar")

SwiftBar.app.zip

dchevell commented 1 year ago

@melonamin no need to apologise, I'm grateful for your work on this app :)

Still beachballed for me on this build. I reproduced before installing (b479), and after (confirmed b494).

Console logs - I clicked "Add" at 09:17:00.567184+1000.

default 09:16:46.884279+1000    SwiftBar    order window front conditionally: cc1 related: 0
default 09:17:00.000746+1000    SwiftBar    Requesting manual refresh for plugin id: batterystatus.sh type: Executable name: batterystatus path: /Users/dchevell/Library/Mobile Documents/com~apple~CloudDocs/SwiftBar/batterystatus.sh
default 09:17:00.000973+1000    SwiftBar    Refreshing plugin metadata /Users/dchevell/Library/Mobile Documents/com~apple~CloudDocs/SwiftBar/batterystatus.sh
default 09:17:00.179980+1000    SwiftBar    Successfully executed script /Users/dchevell/Library/Mobile Documents/com~apple~CloudDocs/SwiftBar/batterystatus.sh
default 09:17:00.567184+1000    SwiftBar    It's not legal to call -layoutSubtreeIfNeeded on a view which is already being laid out.  If you are implementing the view's -layout method, you can call -[super layout] instead. Break on void _NSDetectedLayoutRecursion(void) to debug.  This will be logged only once.  This may break in the future.
default 09:17:00.573292+1000    SwiftBar    order window front conditionally: cc1 related: 0
default 09:17:00.574995+1000    SwiftBar    order window: cc6 op: 1 relative: cc1 related: 0
default 09:17:00.838943+1000    SwiftBar    order window: cc6 op: 1 relative: cc1 related: 0
default 09:18:00.000260+1000    SwiftBar    Requesting manual refresh for plugin id: batterystatus.sh type: Executable name: batterystatus path: /Users/dchevell/Library/Mobile Documents/com~apple~CloudDocs/SwiftBar/batterystatus.sh
default 09:18:00.000361+1000    SwiftBar    Refreshing plugin metadata /Users/dchevell/Library/Mobile Documents/com~apple~CloudDocs/SwiftBar/batterystatus.sh
default 09:18:00.194951+1000    SwiftBar    Successfully executed script /Users/dchevell/Library/Mobile Documents/com~apple~CloudDocs/SwiftBar/batterystatus.sh
melonamin commented 1 year ago

Hmm… interesting, I need to look into it. 🤔

melonamin commented 1 year ago

Manged to reproduce it on my machine, which is very good, I'm getting closer

melonamin commented 1 year ago

@dchevell how about this one? SwiftBar.app.zip

dchevell commented 1 year ago

Same thing I'm afraid @melonamin . Confirmed b495 in the about screen, then captured these logs:

default 06:56:46.238645+1000    SwiftBar    It's not legal to call -layoutSubtreeIfNeeded on a view which is already being laid out.  If you are implementing the view's -layout method, you can call -[super layout] instead. Break on void _NSDetectedLayoutRecursion(void) to debug.  This will be logged only once.  This may break in the future.
default 06:56:46.244944+1000    SwiftBar    order window front conditionally: fea8 related: 0
default 06:56:46.246529+1000    SwiftBar    order window: feb5 op: 1 relative: fea8 related: 0
default 06:56:46.509324+1000    SwiftBar    order window: feb5 op: 1 relative: fea8 related: 0

(One other odd side effect: On prior builds, the sfcolor parameter would only apply to inline symbols, e.g. :circle: | sfcolor=green sfimage=square would make the inline :circle: green, but not affect the sfimage icon placed to the left. On this build, the colour gets applied to both, which made one of my scripts that uses a lot of colour based info kinda weird)

melonamin commented 1 year ago

@dchevell I have a good feeling about this build, can you please try? SwiftBar.app.zip

space-esquire commented 1 year ago

Hi there, same exact thing is happening on Ventura. Do you recommend I go back to the release? Thanks :)

melonamin commented 1 year ago

@space-esquire you've tried the latest one I linked, correct?

space-esquire commented 1 year ago

Yes 😃

melonamin commented 1 year ago

FML then! 🥲

dchevell commented 1 year ago

@melonamin I can't speak for anyone else, but this build finally works for me! Was able to add a shortcut plugin with no errors and run it as expected.

A little weirdness where, after adding one, I can't click on it to highlight or delete - but if I switch to another tab (e.g. Code Plugins) then back to Shortcut Plugins, it resolves that issue.

Apologies for being so long with my feedback!

melonamin commented 1 year ago

That’s awesome to hear, thanks! I’ll check the selection\highlight issue