Customizing Hookmark Integration with DEVONthink

The purpose of this web page is to illustrate how you could customize Hookmark to integrate differently with DEVONthink.

Most DEVONthink users will be content with Hookmark’s default integration with DEVONthink. By default Hookmark identifies DEVONthink items by their x-devonthink-item URL. Therefore, Hookmark’s Copy Link command returns x-devonthink-item URLs.

However, users who primarily use DEVONthink to index folders may prefer an alternative script. When Copy Link is called on an item in DEVONthink with that integration, the resulting URL will have the form hook://file// rather than x-devonthink-item://. This will make the hooks you create in DEVONthink visible when you open the same file in third party apps (a different PDF viewer, like PDFpenPro or Skim, a different text editor like BBEdit, etc.) That’s because in those other apps, Hookmark currently has no way of knowing what the x-devonthink-item:// URL is. Instead, it constructs the hook://file// URL based on the file’s path.

For current information about using Hookmark with DEVONthink, please see Using Hookmark with DEVONthink by DEVONtechnologies.

Custom Get Address script for DEVONthink 3

If you would like Hookmark’s Copy Link command to always return a hook://file/ URL rather than x-devonthink-item URL, then:

  1. Open Hookmark’s Preferences > Scripts tab.
  2. Select DEVONthink on the left.
  3. Click on the GetAddress tab.
  4. Copy and paste the following:

    tell application id “DNtp”
    if exists (content record of current tab of window 1) then
    — current open item
    return path of (content record of current tab of window 1)
    end if

    if class of window 1 is equal to viewer window then
        set selected_items to selection of window 1
        if (count of selected_items) = 1 then
            -- current selected item
            return path of item 1 in selected_items
        end if
    end if
    
    -- selected group
    return reference URL of root of window 1
    

    end tell

Hook to New > DEVONthink

If you choose to use hook://file/ URLs for DEVONthink items, then you should probably avoid using Hookmark’s New Item > DEVONthink menu option. That’s because by default that option identifies created files using the x-devonthink-item URL scheme.

You can delete the default New Item > DEVONthink script. DEVONthink items would then be created with the hook://file/ URL schemes (which is what you want); but those DEVONthink files would be created inside the DEVONthink database rather than inside a folder that is simply indexed by DEVONthink.

So if you want to use hook://file/ URLs in DEVONthink, we recommend creating them via the other Hook to New scripts (e.g., for .txt files or .rtf files). And:

  1. In Notes Preferences choose the folder that is indexed by DEVONthink. Hookmark will then create new files in that folder.
  2. Alternatively, move files that are created via Hook to New into your indexed folder, either manually or via automation. If you want to use automation, consider Hazel which automates moving files.

See also