How to use Hook for Apple Calendar?

I searched in this forum and they can use Calendar and Hook together. I tried as they said but Hook tells me “No linkable item found in Calendar”.

Here is what I did: select one event and then press Control+H. I think I should have selected the event correctly as in this screenshot (sorry for this dense schedule)

Is there anything wrong with my usage? I am using Version 5.1.3 (5475; Integration v. 283).

Sorry about this issue.

After you select the event, you might need wait some time to invoke Hookmark. It is because there is not fast way to get the url of the event.

Thank you

As you suggested, I wait for about 30 seconds before I invoke Hook. But still not work. Possibly because my Hook version is not the latest?

No, you don’t need the latest.

On my Mac, it only requires no more than 10 secs waiting.

What’s your macOS?

Could you please copy the following script and paste it in Script Editor, select a Calendar event, and run the script in Script Editor every 5 secs? Please send us the result.

Thank you

Summary
set sysinfo to system info
set osver to system version of sysinfo

considering numeric strings
	set isVenture to osver ≥ "13"
end considering

set defaultsReply to (do shell script "defaults read com.apple.ical SelectedEvents")
set selectedEvents to parseDefaults(defaultsReply)

if selectedEvents = {} then
	return
end if

set sEvent to the first item of selectedEvents
if isVenture then
	set {eTitle, eventID, calendarID} to sqlQueryVenture(sEvent)
else
	set {eTitle, eventID, calendarID} to sqlQuery(sEvent)
end if
tell application "Calendar"
	set eventReference to "[" & eTitle & "](ical://" & "eventID=" & eventID & "calendarID=" & calendarID & ")"
end tell

return eventReference

on parseDefaults(resultText)
	set localUIDs to {}
	set {TID, text item delimiters} to {text item delimiters, quote}
	set resultItems to text items 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 localUIDs to resultItems's item i
	end repeat
	return localUIDs
end parseDefaults

on sqlQuery(localUID)
	local dateString, localUID
	if localUID contains "/" then
		set {TID, text item delimiters} to {text item delimiters, "/"}
		set {dateString, localUID} to text items of localUID
		set text item delimiters to TID
	end if
	
	set sqlText to "
                SELECT DISTINCT  zcalendaritem.ztitle AS title,zcalendaritem.zshareduid AS eventID
                , znode.zuid as calID
                FROM zcalendaritem
                JOIN znode
                ON znode.z_pk = zcalendaritem.zcalendar
                AND zcalendaritem.zlocaluid = '" & localUID & "';"
	
	set sqlPath to POSIX path of (path to library folder from user domain) & "Calendars/Calendar Cache"
	set {TID, text item delimiters} to {text item delimiters, "|"}
	set {eTitle, eID, cID} to text items of (do shell script "echo " & quoted form of sqlText & " | sqlite3 " & quoted form of sqlPath)
	set text item delimiters to TID
	return {eTitle, eID, cID}
end sqlQuery


on sqlQueryVenture(localUID)
	local dateString, localUID
	if localUID contains "/" then
		set {TID, text item delimiters} to {text item delimiters, "/"}
		set {dateString, localUID} to text items of localUID
		set text item delimiters to TID
	end if
	
	set sqlPath to POSIX path of (path to library folder from user domain) & "Calendars/Calendar.sqlitedb"
	set {TID, text item delimiters} to {text item delimiters, "|"}
	
	set sqlText to "
                SELECT DISTINCT  calendaritem.summary AS title,calendaritem.unique_identifier AS eventID
                , calendaritem.calendar_id as calID
                FROM calendaritem
                WHERE uuid = '" & localUID & "';"
	set {eTitle, eID, cID} to text items of (do shell script "echo " & quoted form of sqlText & " | sqlite3 " & quoted form of sqlPath)
	set text item delimiters to TID
	return {eTitle, eID, cID}
end sqlQueryVenture

I’m having exactly the same problem, “No linkable item found in Calendar”, even if I wait for a minute. I’m on Sonoma 14.1, Hookmark 6.0.1 Setapp edition, and when I try your script, I get an error message:

error "2023-11-02 12:00:46.337 defaults[87555:3631301] 
The domain/default pair of (/Users/USERNAME/Library/Containers/com.apple.ical/Data/Library/Preferences/com.apple.ical, SelectedEvents) does not exist" number 1

Thanks for your help!

Sorry about this issue.

If you run the followng command in Terminal, what do you get?
defaults read com.apple.ical SelectedEvents

If it does not return anything, then try:
defaults read com.apple.ical

Thank you

This is what I get:

> defaults read com.apple.ical SelectedEvents
2023-11-02 22:04:08.145 defaults[94361:3896738]
The domain/default pair of (/Users/USERNAME/Library/Containers/com.apple.ical/Data/Library/Preferences/com.apple.ical, SelectedEvents) does not exist

Thank you.

Can you try this command?
defaults read com.apple.ical

You don’t need post the result here. Just let us know if it return any meaningful result.

Thank you

I also get a “… does not exist”.

Does it work before you upgraded to Sonoma?

It is possible you got a corrupted preferences file or we have different setting for Calendar.

I’m quite sure it didn’t work before Sonoma either. I switched to the hookmark setapp version some time ago and that wasn’t completely smooth: Is it possible that that’s the cause of the problem? Is there anything I can try to reset?

I have the same issue, but for Hookmark worked with Apple Calendar before and now it does not. I do not know if it is Sonoma or not, but I have upgraded to Sonoma and now Hookmark does not work with Apple Calendar any more. Please help!

Welcome to Hookmark forum, @per.becker .

Could you please check this website and see if it can solve your problem?

Thank you

Hi I am running Sonoma 14.0.

The result running your script is Error: unable to open database "/Users/shuffleofficial/Library/Calendars/Calendar.sqlitedb": authorization denied

Sorry about this issue.

Could you please try give Hookmark full disk access in System Settings and see if it resolves the issue? After it works, you may remove this full disk access setting.

Thank you

Thanks for trying to help! However, I have now done the relevant steps on the support page and it is still not working with Calendar. The error appeared recently, so I am starting to think that it may not be Sonoma after all. I did a recent Hookmark update and after that it randomly asks for giving it access again after reboot. Can that input help you figuring out what the problem may be?

There was another Hookmark update today and now Hookmark works with Calendar again. Thanks for solving this issue!

Thank you for the info, @per.becker . I am glad it works for you.

1 Like

I turned on full disk access for hook and it works. But after I remove hook from full disk access, it fails again. I would accept giving hook full disk access as a temporary solution. Thanks a lot.

1 Like

I ask for the same question, I also showed no linkable item despite doing the action right. I would like to open full disk access as a workaround, but in settings Hookmark isn’t an option for full disk access. Is apple calendar supported? Or do I need to download some kind of script to make it work?