Last active
June 26, 2019 20:44
-
-
Save dansheffler/ff35af3059a66b004f35 to your computer and use it in GitHub Desktop.
Applescript for system-wide URL integrating Skim and Bibdesk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on open location skimmerURL | |
set oldDelims to AppleScript's text item delimiters | |
set newDelims to {"sk://", "#"} | |
set AppleScript's text item delimiters to newDelims | |
set bibKey to item 2 of the text items of skimmerURL | |
set pdfPage to item -1 of the text items of skimmerURL as integer | |
set AppleScript's text item delimiters to oldDelims | |
tell application "BibDesk" | |
repeat with currentPub in publications of front document | |
if cite key of currentPub is bibKey then | |
set pdfPath to the first item of linked file of currentPub | |
end if | |
end repeat | |
end tell | |
tell application "Skim" | |
activate | |
open file pdfPath | |
go document 1 to page pdfPage of document 1 | |
end tell | |
end open location | |
on open filelist | |
repeat with i in filelist | |
set filecount to 1 | |
set filename to POSIX path of i | |
set quotedname to quoted form of filename | |
tell application "Skim" | |
activate | |
open file i | |
end tell | |
end repeat | |
end open | |
tell application "Skim" | |
activate | |
end tell |
To get the sk://
registered with the system, the app's info.plist
file needs to contain this:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>Skimmer</string>
<key>CFBundleURLSchemes</key>
<array>
<string>sk</string>
</array>
</dict>
</array>
Note that the page number is the absolute page number like it is with ordinary PDF URLs not the page "label" which could be (e.g.) roman numerals for pages 1--15 then arabic numerals for 16--250. Both of these values can be accessed in Skim via Applescript.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Saving this applescript as an executable app, then reserving
sk://
as the URL namespace, will make links likesk://mccabe94#15
open page 15 of of McCabe's Plato's Individuals.mccabe94
is the cite key for this book in BibDesk and the pdf of the book (which I own and scanned myself btw) is the first linked file for this entry in BibDesk.