xbar-plugins icon indicating copy to clipboard operation
xbar-plugins copied to clipboard

feat: rewrite brew-services plugin

Open jimeh opened this issue 2 years ago • 8 comments

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:

new-brew-services Screen-Shot-2021-11-03-14-05-42 13

Old brew-services:

old-brew-services

jimeh avatar Nov 01 '21 01:11 jimeh

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.

jimeh avatar Nov 02 '21 00:11 jimeh

🙌 I wrote the original plug-in and wholeheartedly endorse this rewrite.

eproxus avatar Nov 03 '21 12:11 eproxus

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.

jimeh avatar Nov 26 '21 10:11 jimeh

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 avatar Mar 01 '22 19:03 jimeh

@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 avatar Aug 29 '22 12:08 martin-braun

@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 :)

jimeh avatar Aug 31 '22 11:08 jimeh

@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 :)

screenshot

jimeh avatar Sep 10 '22 01:09 jimeh

@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.

martin-braun avatar Sep 10 '22 11:09 martin-braun

@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 avatar Jan 25 '23 23:01 sprak3000

@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 :)

jimeh avatar Jan 25 '23 23:01 jimeh

@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 avatar Jan 29 '23 16:01 jimeh

@jimeh

No need for apologies. Thank you for the update. Merged!

sprak3000 avatar Jan 29 '23 21:01 sprak3000

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 avatar Feb 25 '23 07:02 onaforeignshore

@onaforeignshore Thanks for the reminder. I'll sort it a fix in the next day or two.

jimeh avatar Feb 26 '23 06:02 jimeh

@onaforeignshore Brew path detection should be fixed in #1921, feel free to comment there if you have any issues :)

jimeh avatar Feb 26 '23 18:02 jimeh