Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How about click functions? #459

Closed
Hamburgle opened this issue Feb 13, 2018 · 4 comments
Closed

How about click functions? #459

Hamburgle opened this issue Feb 13, 2018 · 4 comments

Comments

@Hamburgle
Copy link

Am I allowed to request a feature? I would like to be able to use bitbar to be able to click on a menu item and in doing so launch a script (preferably Applescipt, but perhaps a shell script). My apologies if bitter already does this (I couldn't see how.)

@jacoblyw
Copy link

jacoblyw commented Mar 6, 2020

As of 2020, this is possible.

Bash.
Put this in your Bitbar folder as doSomething.sh:

#!/bin/bash
# <bitbar.title>Do Something</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author.github>Me</bitbar.author.github>
# <bitbar.author>JL</bitbar.author>
# <bitbar.desc>Do Something</bitbar.desc>


if [ "$1" = 'doSomething' ]; then
 # do something
  open .
fi


if [ "$1" = 'doSomethingElse' ]; then
 # do something
  open ~
fi

# build the menu, this is text with a cat icon
echo "Cat :smile_cat: | color='black'"
echo "---"
#menu entries, this one calls "doSomething" (above) without opening a terminal
echo "Click here to Do something      | color=#f23400 bash='$0' param1=doSomething     terminal=false"
echo "Click here to Do something else | color=#107F01 bash='$0' param1=doSomethingElse terminal=false"

Hope that helps.

@Hamburgle
Copy link
Author

Hamburgle commented Mar 6, 2020

That's interesting, indeed exciting, but I don't see any downloadable version from 2020 on this page: https://github.com/matryer/bitbar/releases so which one do I download? (PS, I just noticed my original post said "bitter" instead of "bitbar". Darn spell auto-correct.) PS, I just tried it on my old version of BitBar (July 2017?) and I have no idea how it worked but it does! FABULOUS! And thanks for throwing in that emoji.

@franzuu
Copy link

franzuu commented Oct 7, 2022

Are clickable items possible with javascript also?
I would like to call a function inside the script. I know it is possible with bash approach, but haven't found a way to do it with javascript. Any help or guidance is appreciated.

@gingerbeardman
Copy link
Collaborator

gingerbeardman commented Oct 7, 2022

If you can call it on the command line, it's possible.

Taking inspiration from this stackoverflow answer: https://stackoverflow.com/a/64093383/28290

  1. create script.js
    #!/usr/bin/env node
    console.log('Hello terminal');
    
  2. make it executable chmod +x script.js
  3. put it in a subfolder next to your xbar script and call it from your xbar script

Also see examples in:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants