joseph schmitt

Shiori Keyboard Maestro Shortcut

Macro-ty Mac... don't talk back.

Aug 09 2013

I recently discovered a fantastic Mac Pinboard client called Shiori. It provides a simple, clean, and best of all fast user interface for accessing and adding bookmarks to Pinboard (and Delicious). Bookmark retreival uses a wonderful little UI reminiscient of Alfred/Quicksilver that makes bookmark search ridiculously easy:

Search Bookmarks in Shiori

Adding a bookmark is similarly nice, and replaces the functional (yet not always delightful) default Pinboard bookmarklet:

Add Bookmark in Shiori

However, one feature I really miss from the bookmarklet is the ability to automatically add any selected text on the web page you're saving as the description of the bookmark. This is a huge timesaver for me, as I like pull-quoting large sections of websites and using them as descriptions; makes finding said web sites later on a bit easier. Bummer.

However, after a few minutes in Keyboard Maestro1, I was able to whip up a shortcut that gets me exactly what I need:

Keyboard Maestro Macro

The logic behind the script is actually pretty straightforward.

Whenever a hot key is triggerd (in my case, Ctrl+Cmd+S), perform the following actions:

  1. Get the current clipboard contents and save it to a variable.
  2. Perform a copy of whatever is currently selected.
  3. Save the new clipboard contents and save that to another variable.
  4. Trigger Shiori (in my case, with Ctrl+Shift+Cmd+S).
  5. Compare the newly copied clipboard text to the previous clipboard:

    1. If they don't match, it means text in your browser was selected and we should use that text to fill in the description field (by pressing Tab2 and then pasting. The last Shift+Tab's is for focusing the keyboard back on the Tag field).
    2. If they do match, then nothing was copied from the browser, so just Tab to the description field and don't do anything else.
  6. Set the clipboard back to its original contents (so you don't lose anything you had in there before you ran this macro).

You can download the macro here. Don't forget to change the hotkeys in the macro to match your setup/preferences. Let me know if you have any suggestions on how to make it better!

  1. I actually adapted this macro from a very similar one I wrote a year or so ago that does the exact same thing in Reeder for Mac. If you're interested, you can download that version here. Will be useful assuming Reeder for Mac returns eventually. 

  2. This macro will need a slight update if you have the Full Keyboard Access option in System Preferences set to "All controls". You'll need to Tab and Shift+Tab twice, otherwise it'll only select the plus button when run. Thanks to Dave Overton for pointing this out.