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 643 forks source link

ticker, selector - save it as an argument? #512

Closed brobee closed 5 years ago

brobee commented 5 years ago

Hi Guys,

Is it possible to implement a selector/ticker in bitbar? My idea is to run a script on different servers with different functions Let's say in the menu, there is an environment submenu with 3 options. I select dev, it saves and I can select the function, for instance build and it initiates my bash script. Optional: input is possible in bitbar?

I use bash, but py would be fine as well, but without any example I'm totally stucked.

echo "environment" echo "--dev" echo "--dev2" echo "--dev3" echo "action" echo "--build | bash=/Users...../bla.sh terminal=false" <= I can modify the script to read the arguments, but I need to pass here them. echo "--unitTest | bash=/......"

Thanks!

gingerbeardman commented 5 years ago

You could read/write a config file.

Read on script run. Write on menu item selection.

brobee commented 5 years ago

Thanks for your comment. Can you please provide a short example?

gingerbeardman commented 5 years ago

Here are some that do that kind of thing:

brobee commented 5 years ago

I found a workaround with submenus using "----", so ticker/selector is not mandatory. (In the example files, I don't see selector and variable assignment)

Anyway, If I have a shell function, is it possible to call that or it works only with individual files?

For instance, it requires files, not functions. echo "--build | bash=/Users...../bla -> echo "--build | bash=bla" bla is a normal function in the same shell file.

gingerbeardman commented 5 years ago

You seem to be thinking about the script as only bitbar commands that you have to squeeze everything into. This is not the case.

You have the complete freedom of a shell script, part of which will generate the bitbar menu. So I would write the script as you need it, with conditional logic for branches, and then when it's working add in the bitbar stuff for "user interface".

If you need help beyond this, you might have some response at StackOverflow.

I'm closing the issue, but feel free to keep in touch here.