matryer / xbar

Put the output from any script or program into your macOS Menu Bar (the BitBar reboot)
https://xbarapp.com
MIT License
17.59k stars 642 forks source link

Cannot call xbar://app.xbarapp.com/refreshAllPlugins #740

Open mlcampbe opened 3 years ago

mlcampbe commented 3 years ago

Maybe I am misunderstanding how this is supposed to work but I am using xbar v2.1.0-beta and if I start xbar from the icon and then in a terminal window I run 'open xbar://app.xbarapp.com/refreshAllPlugins' I get the error:

LSOpenURLsWithRole() failed with error -600 for the URL xbar://app.xbarapp.com/refreshAllPlugins.

But, If I run xbar from the command line by executing /Applications/xbar/Contents/MacOS/xbar that starts xbar in debug/console mode and then from another terminal window 'open xbar://app.xbarapp.com/refreshAllPlugins' works properly.

Am i doing something wrong?

matryer commented 3 years ago

Hey @mlcampbe thanks for your question. Where are you running xbar via the icon from?

mlcampbe commented 3 years ago

The normal mac app way. I double click the icon from the /Applications folder normally. When doing so then the refresh fails as listed above. When I open a terminal window and run the /Applications/xbar/Contents/MacOS/xbar directly then I am able to use the xbar:// API calls. Ideally I would like to be able to use the xbar:// calls when it is launched at login or when opened via the icon.

matryer commented 3 years ago

@mlcampbe thanks - we'll look into this, it sounds like a bug.

mlcampbe commented 3 years ago

I just get the feeling I am doing something wrong here. What is the expected way to use the API calls from within a shell script? For example, I want an existing script to programmatically refresh all plugins. How would I do that from the script. I had been trying to call 'open xbar://app.xbarapp.com/refreshAllPlugins' as that is the only way I know of calling a URL from a script but is that correct?

matryer commented 3 years ago

@mlcampbe yes - in fact, that works for me in Terminal. Does it work if you run that directly in a terminal?

mlcampbe commented 3 years ago

@matryer the behavior I see is that if I open the terminal and run /Applications/xbar.app/Contents/MacOS/xbar directly I see xbar debug output in the terminal window regarding refreshing and cycling and such. If I then open a 2nd terminal window and run open xbar://app.xbarapp.com/refreshAllPlugins it works and the 1st terminal window includes the message 2021/07/14 07:38:08 incoming URL: handleIncomingURL xbar://app.xbarapp.com/refreshAllPlugins.

Instead though if I start xbar by double clicking the icon from the /Applications folder there is no debug output shown anywhere obviously but if I go into a terminal window and run the same open xbar://app.xbarapp.com/refreshAllPlugins it fails with the LSOpenURLsWithRole() failed with error -600 message.

I'd like to be able to call the refresh since I am trying to use one plugin to enable/disable another plugin. For example, if I am running on battery power then I want to display the colorfulBatteryLevel.15m.sh plugin but if I am on AC power to disable it. My script can rename the colorfulBatteryLevel.15m.sh file with the .off extension as needed but I need to call refreshAllPlugins to make that change visible. If there is another way to programmatically enable/disable plugins then let me know and I can try it.

rwproj commented 2 years ago

I've managed to solve the message endpoint error by removing the checkbox "Start at login" in xbar context menu and instead adding the line /Applications/xbar.app/Contents/MacOs/xbar at the end of my ~/.yabairc. If sometimes it starts bugging thats usually when two processes of xbar are running so i kill them both and then just restart yabai which would then launch xbar while starting.