littlebirdyをベースに、パスワード保護がないファイルの保護を自動で外すlittlebirdy-nopasswordを作った
github.com
これをAutomatorのService(AppleScript使用)で自動化する。
phpとgsのインストールが必要
brew install ghostscript brew install php
Automatorを起動してQuickAction(旧Service)を作成
AppleScriptを選択。No input, Any applicationを選択して以下のスクリプトを記述.
tell application "System Events" tell process "Preview" set thefile to value of attribute "AXDocument" of window 1 end tell end tell -- display dialog "my variable: " & thefile -- display dialog quoted form of replaceText(thefile, "%20", space) set thefile to replaceText(thefile, "%20", space) set thefile to replaceText(thefile, "File://", "") -- set newFile to POSIX file thefile set thefile to do shell script "/usr/local/bin/php -r 'echo urldecode(\"" & thefile & "\");'" do shell script "/usr/local/bin/littlebirdy-nopassword " & thefile tell application "Preview" to close window 1 do shell script "open " & thefile to replaceText(someText, oldItem, newItem) (* replace all occurances of oldItem with newItem parameters - someText [text]: the text containing the item(s) to change oldItem [text, list of text]: the item to be replaced newItem [text]: the item to replace with returns [text]: the text with the item(s) replaced *) set {tempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, oldItem} try set {itemList, AppleScript's text item delimiters} to {text items of someText, newItem} set {someText, AppleScript's text item delimiters} to {itemList as text, tempTID} on error errorMessage number errorNumber -- oops set AppleScript's text item delimiters to tempTID error errorMessage number errorNumber -- pass it on end try return someText end replaceText
あとはKeyboard>Shortcutで適当なショートカットを指定する.