ish-app / ish

Linux shell for iOS
https://ish.app
Other
17.1k stars 908 forks source link

Can we run Shortcuts by a command ? #1289

Open Rishi5813 opened 3 years ago

Rishi5813 commented 3 years ago

It would be great if the iSH App could run Shortcuts. For example if you want to get a full desktop experience you can run a Shortcut which opens a app on a command just like vs code’s “code.” Shortcut.

saagarjha commented 3 years ago

By Shortcuts, do you mean shortcuts from the Shortcuts app? I’m not completely sure I understand what you’re asking for.

Rishi5813 commented 3 years ago

Yes, Shortcuts App

saagarjha commented 3 years ago

59, I think?

Rishi5813 commented 3 years ago

Yes, We can add a keyword called run-shortcut and write the name of shortcut we want to run.

Rishi5813 commented 3 years ago

It would be great if we could just open a code editor app by running a shortcut or even automation would work on iSH.

62f commented 3 years ago

image

alias - create a function — fish-shell 3... (1/3) alias - create a function¶ < Synopsis¶ < alias alias [OPTIONS] NAME DEFINITION alias [OPTIONS] NAME=DEFINITION < Description¶ < alias is a simple wrapper for the function builtin, which creates a function wrapping a command. It has similar syntax to POSIX shell alias. For other uses, it is recommended to define a function. < fish marks functions that have been created by alias by including the command used to create them in the function description. You can list alias-created functions by running alias without arguments. They must be erased using functions -e. • NAME is the name of the alias • DEFINITION is the actual command to execute. The string $argv will be appended. You cannot create an alias to a function with the same name. Note that spaces need to be escaped in the call to alias just like at the command line, even inside quoted parts. < The following options are available: < • -h or --help displays help about using this command. • -s or --save Automatically save the function created by the alias into your fish configuration directory using funcsave.

https://fishshell.com/docs/3.1/cmds/alias

francoisvignon commented 3 years ago

but you can mount shortcut folder into iSh and then iSh can access shortcul file.

combining with rc script, you can start iSh who, at startup, fetch a script from shortcut folder ;-)

send from my mobile.


François

Le 20 févr. 2021 à 04:53, Fluzzlesnuff notifications@github.com a écrit :

 To run Shortcuts from the Shortcuts app, iSH would have to have access to Shortcuts files. iSH is sandboxed, meaning that it can only access its own app files. Perhaps iOS has a built-in API for running Shortcuts, but if not, this would not be possible.

That's what I understand about the issue. I am not an iOS developer, and it is possible that I don't know what I'm talking about.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

ppouerct commented 3 years ago

By Shortcuts, do you mean shortcuts from the Shortcuts app? I’m not completely sure I understand what you’re asking for.

There is no use for running shortcuts, but using shortcuts to execute ish commands is very useful and achievable

62f commented 3 years ago

By Shortcuts, do you mean shortcuts from the Shortcuts app? I’m not completely sure I understand what you’re asking for.

There is no use for running shortcuts, but using shortcuts to execute ish commands is very useful and achievable

What's the difference between "running a shortcut" and a shortcut that's 'used to execute iSH commands'?

Arcerion-Dev commented 3 years ago

I don’t think that is possible as iSH is a virtual machine, and can’t actually interact with your devices files let alone open apps or get and execute data from them, unless some modifications are done not actually interacting with the Linux shell. If that is what you mean by “Shortcuts”. If you mean executing a bundle of commands with one command, just use shell script (.sh). Which is a script made up of a bunch of commands and functions. Or, of course, you can also always use alias.

samsalisbury commented 3 years ago

By Shortcuts, do you mean shortcuts from the Shortcuts app? I’m not completely sure I understand what you’re asking for.

There is no use for running shortcuts, but using shortcuts to execute ish commands is very useful and achievable

I can think of many uses for running shortcuts from within iSH, @ppouerct. Being able to do this would allow iSH to control many aspects of the device, like dark mode and focus mode, and to make use of other native apps to process files generated inside iSH, for example.

What's the difference between "running a shortcut" and a shortcut that's 'used to execute iSH commands'?

"Running a shortcut" means invoking an existing shortcut on the device from within iSH. This could be achieved a command similar to open on macOS, or xdc-open on linux, which opens a URL in the default app, because shortcuts can be run via a shortcuts:// URL. Adding this command would also allow opening websites in the default system browser from within iSH.

"A shortcut being able to execute iSH commands" would involve registering a URL scheme for iSH itself on the so that other apps and shortcuts could invoke iSH via its own URL scheme, and use X-Callback URLs to receive the stdout from the command, for example. @62f

samsalisbury commented 3 years ago

I just took a quick look at the code, my thinking is that adding another device similar to the PasteBoard at /dev/clipboard could be used to achieve opening URLs using the iOS native handler. I.e. you write a URL to the device, and iSH asks the system to open that URL. E.g. echo "shortcuts://blah-blah" > /dev/open

If that works, it would be really useful by itself. Maybe it could eventually be extended by also allowing writing a handler binary path for a given X-Callback URL, so that the called shortcut/app could pass data back into iSH once done. E.g.:

# Set up the handler
HANDLER='{ "my-handler": { command: "echo \"$RESULT\"", "shell": "/bin/bash -euo pipefail -c"}}'
echo "$HANDLER" > /dev/handlers

# Invoke the shortcut
URL="shortcuts://x-callback-url/run-shortcut?name=???&input=text&text=???&x-success=ish://my-handler"
echo "$URL" > /dev/open

Hm, my C is not up to scratch, but if you think the design above sounds reasonable, I could attempt to implement this @tbodt ^ (I mean, I would copy/paste the clipboard device code and modify it until hopefully worked...)

ifuchs commented 1 year ago

Has anyone ever found a way to invoke an ios shortcut from ish?

dougpagani commented 1 year ago

I just took a quick look at the code, my thinking is that adding another device similar to the PasteBoard at /dev/clipboard could be used to achieve opening URLs using the iOS native handler. I.e. you write a URL to the device, and iSH asks the system to open that URL. E.g. echo "shortcuts://blah-blah" > /dev/open

If that works, it would be really useful by itself. Maybe it could eventually be extended by also allowing writing a handler binary path for a given X-Callback URL, so that the called shortcut/app could pass data back into iSH once done. E.g.:

# Set up the handler
HANDLER='{ "my-handler": { command: "echo \"$RESULT\"", "shell": "/bin/bash -euo pipefail -c"}}'
echo "$HANDLER" > /dev/handlers

# Invoke the shortcut
URL="shortcuts://x-callback-url/run-shortcut?name=???&input=text&text=???&x-success=ish://my-handler"
echo "$URL" > /dev/open

Hm, my C is not up to scratch, but if you think the design above sounds reasonable, I could attempt to implement this @tbodt ^ (I mean, I would copy/paste the clipboard device code and modify it until hopefully worked...)

This is very good design, it would make for an incredibly versatile adapter as such. It fits within the model too, like /dev/location.

dougpagani commented 1 year ago

I don’t think that is possible as iSH is a virtual machine, and can’t actually interact with your devices files let alone open apps or get and execute data from them, unless some modifications are done not actually interacting with the Linux shell. If that is what you mean by “Shortcuts”. If you mean executing a bundle of commands with one command, just use shell script (.sh). Which is a script made up of a bunch of commands and functions. Or, of course, you can also always use alias.

I'm coming back to this thread a while later to see if there was any progress, and I just thought it necessary to point out for newcomers who may not be able to judge for themselves -- nearly everything in this comment is incorrect and it does more damage to the discussion than it does any good. This commenter either doesn't understand ish or virtualization/emulation on a very basic level. (virtualization =\= emulation, and whether or not something can interact with the host system is not just a matter of if it's a virtual machine. Which ish categorically is not.)

I still love that api design a year later though @samsalisbury . Though I'm unsure how you'd manage handlers past the point of shouting them into existence into the void. Remove, list etc. I guess it could just be more /devs.

62f commented 1 year ago

I don’t think that is possible as iSH is a virtual machine, and can’t actually interact with your devices files let alone open apps or get and execute data from them, unless some modifications are done not actually interacting with the Linux shell. If that is what you mean by “Shortcuts”. If you mean executing a bundle of commands with one command, just use shell script (.sh). Which is a script made up of a bunch of commands and functions. Or, of course, you can also always use alias.

I too WiSH that was true,

’cuz just in time for Halloween, my last 10 months’ work in proving that the WinX Pro ‘Sandbox’ is a hoax, by using WinX Enterprise from a sandbox to attack and absolutely, utterly destroy its host machine’s entire Hyper-V capacity, has been a success. When I knock, it knocks back yet there’s nobody home. ‘’’Unload and reload the SB app, use DISM -reinstall everything from update, FixMBR…(though mine is actually using uEFI secure boot from a hardened USB), SFC /*now’’’ is all the community’s best help could tell me. After seMDing the demonic Rysen to its grave, there’s no resurrection, even after rotating BIOS security keys. I scanned intensely to be sure that it wasn’t any rogue warez responsible, and didn’t use any Store-privileged apps.

dougpagani commented 1 year ago

For those who are looking for a workaround, I found this in the wiki which is absolutely relevant:

https://github.com/ish-app/ish/wiki/Shortcuts-Integration-Workaround

It's a bit DIY and you'll have to know your way around the shell, but if your desire is to use ish from shortcuts, to be able to drop-into shell, it wouldn't make much sense if you are anyways uncomfortable IN shell. But anyways, I may try and make a shortcut & publish it that can make this a bit easier for users. Not as nice as @samsalisbury 's handler & open API, but I think it can have its arm twisted to get equivalent functionality.

Nihilentropy-117 commented 10 months ago

It took me far too much trial and error, but I have developed a way to do this, starting with the outline in the comment above. It’s a little janky, by necessity, but it functions well, and can pass variables back and forth. It can launch a program within iSH from a Shortcut, and then pass variables out of iSH to any URI compatible app, including shortcuts.

https://github.com/Nihilentropy-117/ISH-iOS-bridge/tree/main

It uses root SSH here, and I would definitely advise against that, as well as setting SSH to only accept connections from Localhost. This is really just a proof of functionality though, and I’m so tired of looking at it today.

Scripter17 commented 9 months ago

I'm putting a $50 USD bounty on an actual real iSH "run command" shortcut action and another $50 USD on having it not open the app in the foreground The built-in SSH action is giving me weird and ungoogleable errors that nobody's ever had before and I'm SICK of it

I prefer to use paypal for this but I'm willing to use alternatives if that gets this resolved. Money obviously goes to whoever implements it