State of play with Ulysses?

What is the current situation with Hookmark integration with Ulysses? (I know that @Mistercharlie, @LucB and others have written about this in the past, but I can’t get anything in their posts to work for me.)

If integration is still incomplete / nonexistent, what are the minimal actions that we need from Ulysses’s developers, to get basic Hookmark integration?

Welcome to the Hookmark Forum , @tbm. Ulysses is listed as:

  1. :thinking: : Hookmark integrates with the app using UI scripting because the app lacks an adequate API for linking (possibly no API).

If your language is not set to English, that might be part of the problem.

In what language are the Ulysses menu bar items displayed?

Ulysses lacks automation for linking. so Hookmark uses UI scripting for it. It simulates interaction with the user interface rather than calling a reliable application programming interface.

Compare Manifesto for Ubiquitous Linking and https://hookproductivity.com/help/integration/other-app-developers/ .

1 Like

There is obviously something about this discussion I don’t understand. I don’t have any trouble using HookMark to create a link to a Ulysses sheet. I can easily paste into Ulysses. Ulysses offers a number of good ways to convert documents into different file formats.

What am I missing?

Thanks for asking, @BJB . I have clarified my response above, now saying:

I suspect @tbm is using a language other than English. Or there could be a timing issue because UI scripting is also sensitive to timing issues. Application programming interfaces in contrast are reliable.

Hello LucB,

Many thanks for the extensive answer.

I am using Ulysses in English.

But when I place the highlight anywhere in the GUI (in the sheet, or the sheet list, etc), and hit shift+cmd+spacebar, I get Hookmark’s window with the dreaded “No linkable item found in Ulysses”. I’ve tried this in a variety of ways, and get the same (non-starter) response.

Any suggestions on things to try to address the “timing issues” you mention?

Also, the boilerplate requests to developers to make their apps play nice with Hookmark make it sound quite easy for them to do this. Would it, indeed, be easy for Ulysses’ developers to enable smooth Hookmark integration? Or is this a rather large ask?

cheers,
Tom

Are you using Ulysses from App Store or Setapp?

Thank you

Hello, and thanks for asking.

I am using the Setapp version. Is this a problem?

Best wishes,
Tom

Could you please run the following script in Script Editor and let us know the result? Thank you!


-- if the title repeatedly says  "title-callback"
-- in Terminal do defaults delete com.cogsciapps.hook auth_id
-- see https://discourse.hookproductivity.com/t/hook-cannot-get-title-from-ulysses-sheet/4593/7
use framework "AppKit"
use scripting additions
use framework "Foundation"

tell application "Ulysses"
	activate
end tell


set langStr to ""
try
	set resultText to (do shell script "defaults read com.soulmen.ulysses-setapp AppleLanguages")
	set langIDs to {}
	set {TID, text item delimiters} to {text item delimiters, quote}
	set resultItems to text items of resultText
	text item 1 of resultText
	set text item delimiters to TID
	repeat with i from 1 to (count resultItems)
		if i mod 2 = 0 then set end of langIDs to resultItems's item i
	end repeat
	set langStr to first item of langIDs
	
end try


if langStr is missing value or langStr is "" then
	set langStr to first item of (current application's NSLocale's preferredLanguages as list)
end if
set langID to text 1 thru -4 of langStr
set revealInGroup to "Reveal in Group"
--display dialog langID
set fileMenu to "File"
if langID = "zh-Hans" then
	set revealInGroup to "在组中显示"
	set fileMenu to "文件"
else if langID = "zh-Hant" then
	set revealInGroup to "在群組中顯示"
	set fileMenu to "檔案"
else if langID = "de" then
	set revealInGroup to "In Gruppe anzeigen"
	set fileMenu to "Ablage"
else if langID = "es" then
	set revealInGroup to "Mostrar en el grupo"
	set fileMenu to "Archivo"
else if langID = "fr" then
	set revealInGroup to "Afficher dans le groupe"
	set fileMenu to "Fichier"
	
else if langID = "ja" then
	set revealInGroup to "グループに表示"
	set fileMenu to "ファイル"
else if langID = "ko" then
	set revealInGroup to "그룹에서 보기"
	set fileMenu to "파일"
else if langID = "it" then
	set revealInGroup to "Mostra nel gruppo"
	set fileMenu to "File"
	
else if langID = "pt" then
	set revealInGroup to "Mostrar no Grupo"
	set fileMenu to "Arquivo"
	
end if



-- get Ulysses authorization token
try
	set authId to (do shell script "defaults read com.cogsciapps.hook  auth_id")
on error errMsg
	open location "ulysses://x-callback-url/authorize?appname=Hookmark&x-success=hook://authorization-callback/access-token///"
	return
end try

-- wait until shift and ctrl keys aren't held down
property NSEvent : a reference to current application's NSEvent
property NSShiftKeyMask : a reference to 131072
property NSControlKeyMask : a reference to 262144

set interfering_modifier_down to true
repeat while interfering_modifier_down
	set modifier_flags to NSEvent's modifierFlags()
	set shift_down to ((modifier_flags div (get NSShiftKeyMask)) mod 2) = 1
	set control_down to ((modifier_flags div (get NSControlKeyMask)) mod 2) = 1
	set interfering_modifier_down to shift_down or control_down
end repeat

-- Select Sheets or Library
tell application "System Events"
	tell process "Ulysses"
		repeat 50 times
			if not enabled of menu item revealInGroup of menu 1 of menu bar item fileMenu of menu bar 1 then
				key code 123 using {option down, command down}
			else
				exit repeat
			end if
		end repeat
	end tell
end tell
set the clipboard to ""
delay 0.2
-- get item ID
tell application id "com.soulmen.ulysses-setapp"
	activate
	tell application "System Events"
		keystroke "c" using {option down, control down, command down}
	end tell
end tell
delay 0.1

repeat 25 times -- poll clipboard for ~2.5 seconds
	try
		set s to (the clipboard)
		
		if s is not equal to "" then
			exit repeat
		end if
	end try
	delay 0.1
end repeat
set AppleScript's text item delimiters to "id="
set itemId to text item 2 of s

-- use x-callback to get title
tell application id "com.soulmen.ulysses-setapp"
	set myUrl to "ulysses://x-callback-url/get-item?id=" & itemId & "&recursive=NO&access-token=" & authId & "&x-success=hook://title-callback/targetName///?"
	open location myUrl
end tell
get "ulysses://x-callback-url/open?id=" & itemId

Meaning /Applications/Utilities/Script Editor ( aka Script Editor User Guide for Mac - Apple Support (CA))

Sorry for the delay —

I pasted the script below in Script Editor, closed all other apps, and ran the script.

Ulysses opened to my last-opened sheet.

Script Editor produced an error message, Can’t get text item 2 of “”.

Attached is screenshot of error message.

Thanks for any suggestions on how to get Ulysses via Setapp working, at least somewhat, with your magnificent Hookmark!

Best,
Tom

Could you please run the following command in Terminal then try again? Hookmark will ask for permission to access Ulysses data, please click on Allow button.

defaults delete com.cogsciapps.hook  auth_id

I pasted the command into Terminal, then hit Return. There was a pause, then Terminal returned to command prompt.

Not sure I’d done what was required, I tried again and got a “Defaults have not been changed” message. So I guess I did what was required on the first go.

Anyway, I then ran the Script Editor script several times. Each time it opened Ulysses to the previously active sheet — whatever sheet was active when I closed it down. Each time, too, it asked permission to access Ulysses data.

Happy to supply further data or answer further questions.

Did you give Hookmark permission?

Yes I gave Hookmark permission. (I’m tech-slow, but not THAT tech-slow!)

Sorry, just want to make sure.

It seems it has problem to write the auth id to the user profile. If you run the following command in Terminal, does it return an auth id? You don’t need post the result. I just want to make sure. If it does not return an auth_id, could you please restart your machine and see if it resolves the problem.

defaults read com.cogsciapps.hook  auth_id

Also do you have non-Setapp Ulysses on your mac?

Thank you

I get the following: "The domain/default pair of (com.cogsciapps.hook, auth_id) does not exist”

Which I guess means it’s not returning an auth id?

I didn’t have a non-Setapp Ulysses on my mac — I went to Setapp to economize – but I installed one. I seem to get the same results: highlight either a sheet or that sheet in the sheet list, hit Shift-Cmd-spacebar, and I get “No linkable item found in Ulysses” in Hookmark window, and a request — repeated each time I try this — “Hookmark would like to access your Ulysses library” (which I allow).

Any debugging I can try on either version of Ulysses? I have a 7-day free trial of this new Ulysses subscription before I have to buy it, so I’ll need to uninstall in 6.

Many thanks for your thoughts on this!

Setapp version of Ulysses works with Hookmark on my mac. Sorry I didn’t mean to ask you to download the App store version of Ulysses. Having two of them might cause some problem. So you can delete the App store version for the debugging.

Have you tried restarting the machine and try it? Sorry I didn’t see you mention this.

Also could you please try run the following command in Terminal and post the output here:
1.

defaults write com.cogsciapps.hook  auth_id  test
defaults read com.cogsciapps.hook  auth_id  test
defaults delete com.cogsciapps.hook  auth_id  

Thank you

I did your suggested debug immediately after booting this morning, so I assumed that was enough. But to be safe I rebooted and repeated, with no change.

I’ve removed the App store version of Ulysses. But I had it installed for several months while I tried out Setapp – wonder whether this might be the ultimate source of my problems with Hookmark…?

I ran the three Terminal commands, and got the following (pasted at foot of this message). (BTW I repeated the last one, because I’d inadvertently included an extra space after “auth_id”.)

Many thanks once more!

[tommueller@MacBook-Pro ~ % defaults write com.cogsciapps.hook auth_id test
[tommueller@MacBook-Pro ~ % defaults read com.cogsciapps.hook auth_id test
test
[tommueller@MacBook-Pro ~ % defaults delete com.cogsciapps.hook auth_id
[tommueller@MacBook-Pro ~ % defaults delete com.cogsciapps.hook auth. id
2023-05-09 07:41:02.338 defaults [3113:46761]
Domain (com.cogsciapps.hook) not found.
Defaults have not been changed.
tommueller@MacBook-Pro ~ %

Thank you very much for your patience and your help for debugging!

Please go to Hookmark Preferences window ->Update->Check now to get the latest script, version 275.

Please let us know if there is any problem.

Thank you for supporting Hookmark!

My pleasure — thank you for your tireless work in trying to solve this!

I do have the latest script, version 275.

However, no major change in behavior. With Ulysses open and focus on any part of the UI, and I hit shift-Cmd-spacebar, the Hookmark (Hm) window appears with the by now familiar “No linkable item found in Ulysses” notification.

Small changes have occurred, however.

First, I no longer have to give Hm permission to access Ulysses every time I invoke Hm — Hm appears to have remembered my “yes” from a previous session, and now accesses Ulysses automatically.

Second, before the Hm window appears, I hear two clicks that sound like my system is copying something. Then the Hookmark window appears. Then I hear a third copy-to-clipboard click. (There is nothing new in the clipboard, however.)

Thanks for any further thoughts you may have on resolving this.

One non-Hm workaround is to highlight sheet X in the sheet list, and hit shift-Ctrl-Opt-C (or Ctrl-Opt + click with trackpad), which allows me to select “Copy Callback URL”. I can use this URL to hyperlink directly to sheet X.

Any way to “hook onto" this functionality with Hm? (Sorry again for the noob dreamworld talk here….)