Open n8henrie opened 4 years ago
Hi!
I've been trying to do this using the Base64 Encode
shortcut action and Python's base64
library. Unfortunately, Python seems to need to run in-app, rather than in-extension. You might be able to do something similar using Lua, though!
Lua appears to successfully run in-extension. As such, putting a decode.lua
in the $SHORTCUTS
directory and running lua decode.lua [âš™ Base64 Encoded] | awk '{ print $2 }'
could work!
Additionally, lua-users.org
seems to have published a good base64-decoding script!
I hope this is helpful!
The rest of this response describes my difficulties using Python to create such a script. This might be a known issue. If so, please ignore the rest of this comment.
Unfortunately, running actions in-app opens the application and does not return output to the calling shortcut. Is this expected behavior? For context, I am trying to do something like this:
Shortcut:
+---------------------------------+
📄 Text
A test!
... of standard input
+---------------------------------+
|
+---------------------------------+
âš™ Scripting
[Encode] [📄 Text] with base64
+---------------------------------+
|
+---------------------------------+
📄 Text
python decode.py 'âš™ Base64 Encoded'
+---------------------------------+
|
+---------------------------------+
⚪ A-Shell
Execute shell command
Command(s) 📄 Cmd
Open the app to execute
the commands? [In-App]
Show When Run [No]
+---------------------------------+
|
+---------------------------------+
🔎 Documents
Show [⚪output] in Quick Look
+---------------------------------+
$SHORTCUTS/decode.py
import base64, sys
print(sys.argv)
if len(sys.argv) > 1:
print(base64.b64decode(sys.argv[1]))
If run in-app, as shown, the application is shown, nothing is printed to the console, and Shortcuts displays a warning dialog that states, "No Items / The Quick Look action wasn't passed any items to preview."
When run in-extension, I am told that Shortcuts,
"
Could Not Run Execute Command
Your command failed with error code 1.
Output was: Could not find platform independent libraries
Current thread 0x[hex string omitted] (most recent call first): "
As such, although it seems that base64-encoded input can be given to a-Shell, there appear to be difficulties when the application receiving this input needs to be run in-app.
I haven't tried this yet, but you might be able to use Lua! If Lua scripts can be run in-extension, then a command like this,
lua decode.lua [encoded text] | awk '{ print $2 }'
could work!
Hi, if you run a shortcut in App, you can go back to the Shortcuts app by calling the command "open shortcuts://"
I had expected to effectively pipe text from shortcuts into a command (as stdin) and return the output to shortcuts. The stdout seems to be returned (at least in extension mode), but I can't figure out how to pipe in input
For example:
I've tried with
<<< [Text]
using the magic variable and still no luck.Is this possible?
Thanks in advance, cool project!