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

Terminal param is not working on latest xbar #680

Closed
bluescreen10 opened this issue Apr 1, 2021 · 26 comments
Closed

Terminal param is not working on latest xbar #680

bluescreen10 opened this issue Apr 1, 2021 · 26 comments
Labels

Comments

@bluescreen10
Copy link

The following xbar plugin will not work on version 2.0.35-beta

#!/bin/bash
echo "terminal | shell=/bin/bash terminal=true"

When clicking on the menu it doesn't do anything.

@matryer
Copy link
Owner

matryer commented Apr 2, 2021

@bluescreen10 Thanks for reporting. What do you expect that to do? Open the terminal?

@matryer
Copy link
Owner

matryer commented Apr 2, 2021

@@bluescreen10 does this work for this use case?

#!/bin/bash
echo "terminal | shell=open | param1=/System/Applications/Utilities/Terminal.app

@bluescreen10
Copy link
Author

The example I provided was to exhibit the problem. My use case is slightly different, I'm running a script but want to see the output in the terminal and noticed that terminal=true didn't show the terminal.

@dperfect
Copy link

dperfect commented Apr 2, 2021

@bluescreen10 Thanks for reporting. What do you expect that to do? Open the terminal?

The current README includes this (in the Parameters section):

terminal=.. start bash script without opening Terminal. true or false

Shouldn't the use of Terminal work without extra configuration (e.g., appleScriptTemplate)? I appreciate the option to customize appleScriptTemplate, but it seems to make sense for the default behavior to be something (I believe) most people would expect – i.e., opening Terminal.app with the script, when terminal=true.

Side note: as it's currently worded, it's also ambiguous whether the terminal option is disabling or enabling the use of Terminal when set to true.

FYI - in my use case, I'm trying to get it to work with the "SSH Menu" plugin (adapted for xbar). In BitBar, it would open Terminal with ssh and the given parameters so you could quickly open an SSH connection to a list of hosts.

@matryer
Copy link
Owner

matryer commented Apr 3, 2021

@dperfect @bluescreen10 thanks, you're both right. terminal=true should open it in a terminal. terminal=false will run it as a background task.

This isn't currently working as expected, and needs a little more work, so I'm going to mark it as a bug.

@matryer matryer added the bug label Apr 3, 2021
@matryer
Copy link
Owner

matryer commented Apr 3, 2021

Can you try the "Run in terminal" option in the menu and confirm that it is working?

@dperfect
Copy link

dperfect commented Apr 3, 2021

The "Run in terminal" option works for me (v2.0.39-beta).

@matryer
Copy link
Owner

matryer commented Apr 5, 2021

I have moved Run in terminal into the xbar folder, and next up we need to add support for terminal=true param, which should do the same (or a very similar) thing.

@C4Wiz
Copy link

C4Wiz commented Apr 23, 2021

I have moved Run in terminal into the xbar folder, and next up we need to add support for terminal=true param, which should do the same (or a very similar) thing.

has this been merged?

@knaccc
Copy link

knaccc commented Apr 26, 2021

Thanks for looking into this issue. FYI, my use case is: I was previously using bitbar to run certain commands that require sudo password input (such as for mounting certain types of drive via FUSE). Something changed when I upgraded to xbar, and now a terminal no longer pops up when password entry is required.

@ruxpendp
Copy link

ruxpendp commented May 1, 2021

Running into this same issue on xbar 2.0.35-beta with macOS Catalina 10.15.7. Sounds like y'all got things handled but I wanted to add some further info.

The following example script:

#!/bin/bash

echo "foo"
echo "---"
echo "click me | shell=\"echo hello world\" terminal=true"

does not open the terminal in xbar 2.0.35-beta like I would expect it to. However the same example app (with bash replacing shell) does open the terminal and echo hello world in bitbar 1.9.2.

I also noticed that my xbar.config.json has terminal.appleScriptTemplate instead of the terminal.appleScriptWithVarsTemplate that's specified in the readme (also, I didn't create this file, nor does replacing the key with the one in the readme seem to solve the issue).

Thanks in advance!

@waverunner
Copy link

Has this issue been addressed yet? I'm running 2.0.42 and having same issue.
Actually my use case is similar to above; I have a bitbar plugin that presents a list of hosts I can ssh to, and no terminal is ever brought up.

@bluescreen10
Copy link
Author

bluescreen10 commented Jun 11, 2021

for now you can work around it with
echo "What I want to run | shell=osascript param1=-e param2='tell application \"Terminal\" to do script \"my script\"' | ...

@mlcampbe
Copy link

I am hitting this issue as well. Have the changes been checked in so that I could download/compile my own version or do we have a timeframe that we might see this implemnted.

I did try bluescreen10's approach as listed above and it does run the script but the terminal app does not start so I can't see the output.

@hdp-sami
Copy link

Has there been any movement on this issue? It's something I used heavily in BitBar and would love to see it back in Xbar.

@knaccc
Copy link

knaccc commented Aug 23, 2021

@hdp-sami This worked for me:

echo "command_description_here|shell=osascript param1=-e param2='tell application \"terminal\" to do script \"/path/to/my/script.sh my_param1  my_param2\"' refresh=true"

Sometimes this causes xbar to crash, so I just need to restart xbar and try again. Also note that triggering the command from the xbar menu will cause the terminal app to appear in the background somewhere so you can provide input, but it won't be on top so you'll need to click the terminal icon on your dock to see it.

@hdp-sami
Copy link

@knaccc Thanks. I can confirm that solution is working for me. It would still be lovely to have the native "terminal" switch usable again but I can definitely work with this.

matryer added a commit that referenced this issue Aug 28, 2021
@matryer
Copy link
Owner

matryer commented Aug 28, 2021

Thanks for bearing with us here, I've been working on this today and I think I've got a solution that works. @hdp-sami and @knaccc would you be able to help me test it? It's in the new release.

@C4Wiz
Copy link

C4Wiz commented Aug 28, 2021

ssh.sh pluging still does not work on the new release

@knaccc
Copy link

knaccc commented Aug 28, 2021

@matryer Thanks for your work on this! There is an improvement with the beta, but I get two terminal windows appearing in the foreground instead of one.

To recap: if I use the "osascript/tell application terminal" workaround method I posted above, this causes a single terminal window to appear, but in the background. Therefore I can simply click the terminal icon on the dock to get to it.

With this new beta, I can successfully use terminal=true instead of the osascript workaround, and a terminal window does appear in the foreground. However, two terminals are displayed in the foreground. One is a regular terminal with an interactive prompt. The second terminal window is the one that launches my bash script and allows me to provide input, such as a sudo password.

matryer added a commit that referenced this issue Aug 28, 2021
@matryer
Copy link
Owner

matryer commented Aug 28, 2021

@knaccc thank you for helping get this right. I couldn't get your version to properly work, but I found another approach that is working. Please test the new release.

@knaccc
Copy link

knaccc commented Aug 28, 2021

@matryer Working perfectly, thanks!!

@C4Wiz
Copy link

C4Wiz commented Aug 29, 2021

i don't understand what im missing here? what needs to be added and where to make it work?

here is the plugin:

#!/bin/bash
#
# Quickly SSH to your favorite hosts
# The list of hosts are extracted from ~/.ssh/config
#
# <xbar.title>SSH</xbar.title>
# <xbar.version>v1.0</xbar.version>
# <xbar.author>Thameera Senanayaka</xbar.author>
# <xbar.author.github>thameera</xbar.author.github>
# <xbar.desc>Quickly SSH to your favorite hosts listed in your ~/.ssh/config file</xbar.desc>
#

echo "SSH"
echo "---"
awk '/^Host / && !/\*/ {print $2" | bash=ssh param1="$2}' ~/.ssh/config terminal=true

output of run in terminal:

 ~ %  '/Users/Dave/Library/Application Support/xbar/plugins/ssh.sh'
SSH
---
Pi-Hole | bash=ssh param1=Pi-Hole
Server | bash=ssh param1=Server
Dakboard | bash=ssh param1=Dakboard
OSMC | bash=ssh param1=OSMC
HomeBridge | bash=ssh param1=HomeBridge

@knaccc
Copy link

knaccc commented Aug 29, 2021

@C4Wiz try:
awk '/^Host / && !/\*/ {print $2" | shell=ssh param1="$2 " terminal=true"}' ~/.ssh/config

@C4Wiz
Copy link

C4Wiz commented Aug 29, 2021

@C4Wiz try:
awk '/^Host / && !/\*/ {print $2" | shell=ssh param1="$2 " terminal=true"}' ~/.ssh/config

yep, that works perfectly! thank you so much

@matryer
Copy link
Owner

matryer commented Aug 31, 2021

Thanks everyone.

@matryer matryer closed this as completed Aug 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants