Skip to content

Instantly share code, notes, and snippets.

@scmx
Last active November 21, 2023 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scmx/e950f64bc50ff42b12daae5d3ec7ef91 to your computer and use it in GitHub Desktop.
Save scmx/e950f64bc50ff42b12daae5d3ec7ef91 to your computer and use it in GitHub Desktop.
Generate QR code macOS quick action open in Preview.app #qrencode #automator

Generate QR code macOS quick action open in Preview.app

#qrencode #automator

A little automator script for adding a right click menu Services -> "Generate QR Code and open in Preview"

brew install qrencode cli for creating QR code. (brew info qrencode)

Open Automator.app -> Add a new Quick Action (service) -> Add "Run Shell Script"

dir="$(mktemp -d)"                        # create a temporary directory
file="$dir/QR-$(date +%Y%m%d-%H%M%S).png" # filename with timestamp in it
/opt/homebrew/bin/qrencode -o "$file"     # generate QR code and save to the file
open "$file"                              # open the PNG file (with Preview.app by default)

Chrome has this feature for URLs, but only for https. Which is problematic when you want to view a page on a mobile phone while using a server without https.

It could be taken a step further to also find the local network ip address.
🤔 that could be a different quick action that replaces the selected text.
I have an alias ip="ifconfig | grep -E '192' | cut -c7- | cut -d ' ' -f1" for finding my local network ip address.
You can also hold Option will clicking on Wifi symbol to see your local network ip address.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment