Introduction
In my last blog post, I provided an outlook on running a shortcut that summarizes a webpage on an iPhone or iPad. Since it’s not possible to run Go on iOS, we need a computer that can be reached via SSH from your device. For constant access, it should preferably be up and running 24/7. For me, my MacBook Pro would be a good choice, but when I use my iDevices, I close the lid, so the iDevices have no chance to connect.
Choosing the Right Machine
I have two machines running all the time in my network: a Synology NAS and a Raspberry Pi 4 with 4GB of RAM running Ubuntu 24.04 LTS. Because I am not very experienced in cross-compiling with Go or creating Docker images, I decided to go with my Raspberry Pi.
Since I’m only running Fabric with cloud LLMs, in my case with OpenAI, there is no need for a lot of computing power, so the Raspberry Pi is more than sufficient.
But in the end, you can use any computer system that runs Go.
Preconditions
You need to have a little expertise in Linux/Unix and the Command Line Interface (CLI). Besides the installation of Go (see the next chapter), you should also set up SSH on your Raspberry Pi, because the Shortcut will call Fabric via “Run Script over SSH”. You should also install git
to access the Fabric repository on GitHub, ffmpeg
for running the yt
command, and wget
to follow some of my experiments later on:
sudo apt install git ffmpeg wget
Installation of Go and Fabric
If Go isn’t already installed, you have to install it first. I followed the “official” method as described on the GO website:
- Ensure there is no previous version installed by checking if the folder
/usr/local/go
exists. If it does, delete it withsudo rm -rf /usr/local/go
. - Download the latest arm64 version for the Raspberry Pi.
- Install Go. Depending on where you downloaded the archive, for me it was:
tar -C /usr/local -xzf $HOME/Downloads/go1.23.0.linux-amd64.tar.gz
. - Add the necessary path information. For the setup in my case $HOME/.zshrc. For the shortcut call, I created and used a special shell limited configuration file, similar to my macOS setup, called
.fabenv
, and added the paths there: export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin
- Install Fabric directly from the repository:
go install github.com/danielmiessler/fabric@latest
. - Set up Fabric with
fabric --setup
. Before doing so, read the next paragraph. - Install
yt
if you want to analyze YouTube videos:go install github.com/danielmiessler/yt@latest
, but be sure to add your YouTube API key.
Troubleshooting Fabric Setup
When I wrote this, the setup failed at the end when copying the patterns, with the error stream error: stream ID 3; CANCEL; received from peer happened
. However, the installation and setup completed all the necessary tasks. The only things missing are the folders for the patterns, sessions, and contexts. After copied them from my macOS installation, Fabric ran fine. I hope someone can figure out why the setup fails so I can delete this paragraph ;-). If you use another computer as a server or another OS on your Raspberry Pi, it might work.
Update 2024/09/23: When using an Ethernet cable to connect the Raspberry Pi 4, everything works fine. This suggests that the issue may be related to the speed or bandwidth limitations of the Wi-Fi chip.
Validating the Installation
All the other information in my blog post Installation and Getting Started with Fabric is still valid. For example:
echo "Two parrots on a skyscraper rooftop" | fabric --stream --pattern create_logo
works just like on the Mac.
The “Run Script over SSH” Mystery
As I already mentioned in my previous blog post Summarizing Websites with Fabric and Apple Shortcuts, there is some mysterious behavior with Shortcut variables inside and around the shell action, both local and remote.
Passing the URL
For the “Run Script over Shell” action, I tried several ways to pass the URL into the action until I found a hint somewhere on the web that the easiest way is just to use variables inside the script box:
As you can see, this is an example in the macOS Shortcuts app, and it works fine. You can use this solution instead of the workaround in my previous blog post.
I initially thought that if it works on macOS, it should also work in the iOS/iPadOS Shortcuts app. So, I copied the shortcut. However, it didn’t work at all, which was frustrating.
After hours of experimenting, I found that this construct works, though I’m not sure why the easy one line command doesn’t work:
Using curl
Instead of wget
There is another command to download the content of URLs in the Linux and macOS toolbox: curl
. Out of curiosity, I tried this command. To my surprise, there is no need for the complex construction that I had to use with wget
.
Although I’ve been using wget
for ages, I think I have to switch over to curl
. Because of all the trouble, I didn’t go the extra mile to extract the text from the HTML with pandoc
. So this will be the preferred solution.
An Unexpected Working Solution
For the sake of completeness, here is another approach. During my experiments, I made a small mistake and ended up with this command, which surprisingly works as well:
I assume it might be because the variable URL
is internally treated as some kind of structure that always has all information available, and some magic fetches the right value for a given context. For example, if you just echo the variable URL
, the output is simply the URL.
The iOS/iPasOS Shortcut
The workflow is the same as in the macOS workflow:
- Use
Receive What’s Onscreen
to work in all web browsers. - Assign the URL of the active website to the variable
URL
. - Assign the title to the variable
name
. - Delete
:
and/
in the variablename
, because these characters cause issues in file names (this could be extended to other characters like?
). - Use
Run Script over SSH
with the IP address or name of your server, the user and password, and the script discussed above. - Put the result into the variable
summary
. - Create the note for Obsidian in a text box, including the properties section and, if needed, a footer area.
- Save it with the Create Note action of the ActionForObsidian (AFO) Shortcuts Extension App.
- Use “AFO” to open the newly created note.
I use “AFO” to save the note in my Obsidian vault because it’s very easy to handle. It is worth investing in this extension, as its collection of Obsidian-related actions helps bridge the gap between the Shortcuts app and Obsidian. Nevertheless, you can also use the save-file
action or move the result to the Notes app.
Conclusion
This is just an example of how to integrate a remotely running Fabric installation into iOS/iPadOS Shortcuts. This approach opens up a universe of possibilities. Anything that runs on a remote machine and consumes text input or creates text output on the terminal (stdin/stdout) can be used to create complex workflows with Fabric, thereby easily becoming AI-supported.
I hope this blog post is overall helpful, despite the little hurdles. It would be great if someone could explain the mysterious behavior of the URL
variable. I would also love to learn how to avoid the Fabric setup error. Critics, kudos, more ideas, and whatever else—please leave them in the comments.
Leave a Reply