From dfbedc02b0c250644b98da0653d2ac5ca971a477 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Thu, 7 Nov 2013 13:17:04 -0800 Subject: [PATCH] add scripts to send links to Safari's Reading List --- add-to-reading-list | 11 +++++++++++ chrome-to-reading-list | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100755 add-to-reading-list create mode 100755 chrome-to-reading-list diff --git a/add-to-reading-list b/add-to-reading-list new file mode 100755 index 0000000..72e1319 --- /dev/null +++ b/add-to-reading-list @@ -0,0 +1,11 @@ +#!/bin/sh + +TITLE="$1" +URL="$2" + +if [[ "$TITLE" != "" ]] && [[ "$URL" != "" ]]; then + osascript -e "tell application \"Safari\" to add reading list item \"${URL}\" with title \"${TITLE}\"" +else + echo "usage: `basename $0` <url>" + exit 1 +fi diff --git a/chrome-to-reading-list b/chrome-to-reading-list new file mode 100755 index 0000000..98a5f8e --- /dev/null +++ b/chrome-to-reading-list @@ -0,0 +1,20 @@ +#!/bin/bash + +AS_GET_TITLE=' + tell application "Google Chrome" + set frontIndex to active tab index of front window + get title of tab frontIndex of front window + end tell +' + +AS_GET_URL=' + tell application "Google Chrome" + set frontIndex to active tab index of front window + get URL of tab frontIndex of front window + end tell +' + +TITLE=`osascript - <<<"$AS_GET_TITLE"` +URL=`osascript - <<<"$AS_GET_URL"` + +~/bin/add-to-reading-list "$TITLE" "$URL"