DEVONthink and Trickster integration

Oh, this is interesting. I wasn’t aware of this hidden setting. I can later try to look at enabling it and seeing what needs to be done in Trickster itself but for now the file-based solution will need to be used.
Note that Hook has a shortcut for Copy to a Hook file, so it’s just a shortcut away, if you’re using Hook.

Sounds great - much appreciated

I enabled this but what I see is that (except this failing at AppleScript stage because it’s not a file) is that the rule is triggered only if the folder is opened in the main list of item in DEVONthink (which would make it show in the preview pane), not just clicked in the sidebar. This is what the hidden preference’s name implies, too.

That would be very helpful if it worked in that situation.

Plus the workaround to get the Open event in that situation is likely simple - just click the parent Group name in the breadcrumb path above the main list.

@Jacob, thanks for the reply!

It’s working now. After I wrote, the system finally asked permission to grant access / control between DT and Trickster. I don’t know why it didn’t do it immediately, or even after several attempts at it. In any case, it’s working now.

(Similarly, only this morning did it ask to grant Trickster access to Photos. I didn’t do anything other than restart my laptop.)

I do have a follow up question.

It seems that Trickster only works on files opened by DEVONthink, whether that’s with DT’s file viewer or its preview pane. Correct?

However, many of my files are indexed, and I have the default action to open them in the default external app. When I open such a file (eg, DT opens an .rtf file with TextEdit), Trickster does not recognize this as opened, neither by DEVONthink nor TextEdit.

I would think one or the other (if not both) would register in Trickster. Is there a way to do so?

Hi, thank you for bring this issue to my attention. I’ve looked at this and have a partial solution but it also looks that there’s a bug in DEVONthink for full support of this.

First of all, it look like opening the document externally from DT indeed doesn’t register in Trickster. My guess is that the approach DT uses to launch an external application may not be registering on the OS level and thus the information doesn’t arrive to Trickster either.

Now, on DEVONthink level itself, you can modify the Smart Rule condition to also fire when “Open Externally” condition is met like in the screenshot below. I tried this but it only seems to work when opening in an external tool using “Open With” in the context menu, not when the document is opened by an external tool by double-clicking on it, when that option is enabled in DT’s preferences, like in your case. This latter behaviour (not running the Smart Rule when double-clicking) I would consider a bug in DEVONthink since I’d expect “On Open Externally” to fire regardless if I double-clicked on a file to open externally or used “Open With”. Please contact DEVONthink’s support about this, if this is important.

It may make sense for me to update the Smart Rule to include “On Open Externally” by default but until this bug is fixed in DT, it will be of limited use.

@Jacob, thanks.

I see the same behavior on my end. Hm.

I’ll report it to DT, both directly and on this related thread, in case you want to chime in or follow along.

1 Like

Thanks Jacob, I really appreciate your customer support. I didn’t think about Hook, but now use it along the lines you suggested. DNT + Trickster + Hook is awesome.

1 Like

This does indeed work well with Hook - thanks

1 Like

A kind of a temporary workaround
Bind it a key

BTW, @Jacob, a strange behavior of add recent function… If you remove a delay in this script - all goes without an error, but recent item is not added…

The script is quick, and if it is possible to remove the delay, then one can create a smart rule for “on open” event for the Group using this script.

-- Script to add selected DT Group to Trickster's Recents
-- Created by Silverstone on 12.07.2021

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

tell application id "DNtp"
	set theRecords to (get selection)
	if (count of theRecords) = 1 then
		
		-- Data for recent item
		set theRecord to item 1 of (get selection)
		set {GroupURL, GroupName, GroupLocation} to {reference URL, name, location} of the theRecord
		set AppName to name
		
		-- Finding or creating 'Group Links' DT group in Inbox of current database to store all link files
		set theFound to search "name==Group Links kind:group" in the incoming group of current database
		if (count of theFound) is 0 then
			set theGroupLinks to create record with {name:"Group Links", type:group} in the incoming group of current database
		else
			set theGroupLinks to item 1 of theFound
		end if
		
		-- Finding or creating the bookmark
		set theFound to search "name==" & GroupName & " url==" & GroupURL & " kind:bookmark" in theGroupLinks
		if (count of theFound) is 0 then
			set theLink to create record with {name:GroupName, URL:GroupURL, type:bookmark} in theGroupLinks
			delay 3
		else
			set theLink to item 1 of theFound
		end if
		set thePath to path of theLink
		
		-- Creating the recent item in Trickster
		tell application "Trickster" to add recent thePath source AppName displayPath GroupLocation callbackURL GroupURL bundleID "com.devon-technologies.think3"
	else
		display dialog "Choose a Group" buttons {"OK"} default button "OK"
	end if
end tell
2 Likes

DEVONthink says they will fix this double-click issue in their next release.

OMG, this is an amazing solution - creating and saving the link in DEVONthink itself. You’re much knowledgable about AppleScript (and obviously DEVONthink) than I am.

I’ve copied this into the Script Editor and saved it as a file. Here’s the download:

Screen Shot 2021-07-12 at 17.48.10

I then looked for a quick way to use it and I noticed that the Scripts Folder of DEVONthink has a Toolbar menu. So I copied the script file there and after restaring DEVONthink, I right-clicked on the toolbar, selected Customize Toolbar, and dragged the script from there to the real toolbar:

Now I can select a group and click that icon in the toolbar to run this script and see it in Trickster. :exploding_head:

Here’s a modified version of the original integration script (courtesy of @DEVONtech_Jim, which I just restyled) which also shows the database name in Trickster, in start of the path. I chose to show the database name in like [database] but you can edit the script to restyle it. Download by clicking on the link.

Screen Shot 2021-07-12 at 17.45.57

Here’s what it looks like in Trickster:
Screen Shot 2021-07-12 at 17.46.44

If you use this script, delete or disable the other one, since they do the same thing just a bit differently.

2 Likes

Outstanding solution - huge thanks

This is appreciated, I use it everyday

I could do a better integration, but function add recent is buggy. It requires about 3 second of delay before it can do something.

I don’t think that add recent is buggy. In the other scripts, add recent doesn’t require a delay. But add recent command does require an existing path and thePath in your script is dependent on DT’s creating the link file in its database folder. Your script delays when it creates a new link file but not when an existing one is found. So I think the delay comes from DEVONthink’s implementation of creating the new record.

It may be as well. I tried to make a wait block with ‘exist’ command - no luck. I guess I need to be more specific about disk write timing…

But, from the other hand, I set thePath variable before the ‘add recent’ function and it gets the right value

Anyway, if the function does not add the recent item for this or that reason - it should generate a human readable error

1 Like

@Jacob, I made some tests and tend to think that the problem is not in Devonthink. After DT creates a new bookmark, I get its path and check with a shell script do shell script "test -f " & quoted form of thePath. It shows that the bookmark file exists on the disk before script runs add recent function, as well as other input data. So, the problem is somewhere in this function and/or Trickster.

@Silverstone I’ll take a look at that and check what happens on Trickster side when there’s no delay.