xbar-plugins
xbar-plugins copied to clipboard
feat: rewrite brew-services plugin
This is a complete rewrite of the brew-services plugin, based on my brew-updates plugin.
Main functional differences from the original plugin is the option to group started/stopped services together, visual style being a bit different, an option to uninstall stopped services, and overall it doesn't suffer from any of the bugs that I'd run into with the old one.
I'm not sure what the policy is with a wholesale plugin rewrite/replacement like this, so I'm happy to make any changes as needed :)
Screenshots
New brew-services:
Old brew-services:
Apologies for the force pushes, I came across a couple of bugs related to some edge cases and issues with brew services itself. These have now been addressed.
🙌 I wrote the original plug-in and wholeheartedly endorse this rewrite.
Apologies for the force pushes. I've simply been updating my PR's here to include updates/fixes I've been making in my dotfiles.
That said, I do not expect to make any further changes for some time, as I've now resolved all annoyances I've had with this script.
Latest force push brought in the latest fixes from my dotfiles repo to add support for the new scheduled
and none
service statuses, and also switches from parsing the plain text output of brew services list
, to parsing the JSON output when passing the --json
flag. This should ensure the script is less likely to break due to future changes to brew services.
@jimeh Excellent work! May I make a feature request before this PR gets accepted? It would be nice if I could hide some services in a sub-menu, because they are getting installed by other packages for their libs, but I don't use their services.
I.e. I install php and get a service along, but I only use php from the command line. I really wish those to be hidden in a sub menu and not counted as well.
A blacklist config would be sufficient, but a way to hide and unhide entries via the context menu would be superior.
Also, I think the 2nd number in the menu should represent the total number of all (unhidden) services instead of all stopped services. 2/5
reads to me as "Two services of five services are active" and not "2 active, 5 inactive". Would feel natural for me. Could also be configurable for full customization.
Thank you.
@martin-braun thanks for the feedback, I'll see what I can do adding some state to the plugin to enable a hide/unhide menu item :)
And you are right, 3/14
in the menu bar does look like 3 out of 14 are running, rather than 3 running / 14 stopped
as it reads when you open the menu. I'll probably just change it to show only the running count, or maybe make it configurable, we'll see :)
@martin-braun I've updated the plugin. Main number display now only shows running services, and hide/show option is available on services, along with an option to enable/disable groups too while I was already adding support to save state :)
@jimeh This is awesome, thank you so much ❤️! I think it is much better with only one number to save some precious real-estate in the top bar. And finally, I can hide those services that I never need. Awesome work!
Now for pure perfect this bulb would turn off when no services would run, but the emoji table offers nothing. I'm happy nonetheless.
I hope your plugin will be merged eventually. Great contribution.
@jimeh
Tried running this plugin, but I don't have any services managed / installed by brew. This results in the plugin throwing an error. Any chance you could update the plugin to account for this behavior?
@sprak3000 Ah, damn. That's one edge case I hadn't encountered myself... lol
I'll put a fix together tomorrow when I'm back on a computer :)
@sprak3000 apologies for the delay, this week turned out busier than I expected. But I've pushed a new v3.0.1 which works correctly when brew services list --json
returns nothing.
@jimeh
No need for apologies. Thank you for the update. Merged!
Another check for all Homebrew plugin authors. Homebrew now installs in /opt/homebrew/bin/brew on any ARM Macs by default. Only checking /usr/local/bin/brew is insufficient.
@onaforeignshore Thanks for the reminder. I'll sort it a fix in the next day or two.
@onaforeignshore Brew path detection should be fixed in #1921, feel free to comment there if you have any issues :)