Hookmark integration to Spaces app

Hi Team,

Trust you are doing well!

I was wondering if you can help setup a hookmark script so that Spaces. app can be onboarded to our list.

I see that in Spaces, there is a “Copy Link to Note” option, either when you directly right click a note (in the notes list), or through the “Note” menu option in the menubar while the note is active.

Please point out some resources to AppleScript that can help me learn how to build this (so I can contribute if I can). It would be great if you could comment your script to explain what’s happening in it.


Thank you for requesting Spaces integration.

Here is the script you can try on your mac. To integrate Spaces to Hookmark, go to Hookmark Preferences window → Scripts ->Click on “+” button, Find Spaces and add it. Copy the following script and paste it Get Address script editor for Spaces, click on Save button.

Please let us know how it goes.

Thank you

Get Address Script

use AppleScript version "2.5"
use framework "Foundation"
use scripting additions

on urlDecode(input)
	tell current application's NSString to set urlString to stringWithString_(input)
	set theDecodedURL to urlString's stringByRemovingPercentEncoding -- 4 is NSUTF8StringEncoding
	return theDecodedURL as Unicode text
end urlDecode

set theURL to path to application id "app.marvey.spaces"
set appBundle to current application's NSBundle's bundleWithURL:theURL
set shortVersionString to (appBundle's objectForInfoDictionaryKey:"CFBundleShortVersionString") as string

set langStr to ""
	set resultText to (do shell script "defaults read app.marvey.spaces 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 copyLink to "Copy Link to Note"
set copyTitle to "Copy Title"
set noteMenu to "Note"

if langID = "zh-Hans" then
	set copyLink to "复制链接到注释"
	set copyTitle to "复制标题"
	set noteMenu to "注意"
else if langID = "de" then
	set copyLink to "Link in Notiz kopieren"
	set copyTitle to "Titel kopieren"
	set noteMenu to "Notiz"
else if langID = "fr" then
	set copyTitle to "Copier le titre"
	set copyLink to "Copier le lien vers la note"
	set noteMenu to "Noter"
end if

delay 0.1
set the clipboard to ""
delay 0.1
set theURL to ""
set theTitle to ""
tell application "System Events" to tell process "Spaces"
	click menu item copyLink of menu noteMenu of menu bar 1
	delay 0.05
	repeat 50 times -- poll clipboard for ~2.5 seconds
			if (the clipboard) is not equal to "" then
				set theURL to the clipboard
				exit repeat
			end if
		end try
		delay 0.05
	end repeat
	set the clipboard to ""
	delay 0.03
	click menu item copyTitle of menu noteMenu of menu bar 1
	delay 0.05
	repeat 50 times -- poll clipboard for ~2.5 seconds
			if (the clipboard) is not equal to "" then
				set theTitle to the clipboard
				exit repeat
			end if
		end try
		delay 0.05
	end repeat
end tell

return "[" & theTitle & "](" & theURL & ")"

1 Like


Thanks a lot for the quick response on this request!
The script works well for notes with a title no longer than 2 words. Titles with 3 or more words show up as a mangled string with % in between the words, and becomes less intelligible.
So I could restrict my note titles to two words, or let me know if there’s a workaround for this.


Could you please post a screen shot? I couldn’t reproduce it. Also, what’s your system language?

Thank you


Here’s a screenshot where there’s no issue:

Here’s a screenshot for the other three notes, with the issue:

My System language is set to US English.


Do you mind post the problematic note here?

If I create a note with title “ISO27001 and ISO27002”, it looks fine.

Thank you


I have pasted the contents of the file. I’m new to Spaces myself, so I don’t see a better way to share the note itself.

# ISO27001 and ISO27002

The _ISO27001_ standard provides requirements to secure organizational processes, in tandem with the _ISO27002_ standard, which provides detailed controls to achieve those requirements.

As of today (June 2023), ISO27001 has had an update in the form of ISO27001:2022. However, ISO27001:2013 is still in vogue, and will remain so for an year or two. Both are similar to a certain degree, and so we have:
* [[ISO27001:2013]]
* [[ISO27001:2022]]
* [[Differences: ISO27001:2013 & ISO27001:2022]]

Similarly, for ISO27002:
* [[ISO27002:2013]]
* [[ISO27002:2022]]
* [[Differences: ISO27002:2013 & ISO27002:2022]]

Actually, I deleted my existing note, and pasted these contents. Then it somehow corrected itself

Is this a bug in Spaces?

I create a new note with your note content and it seems OK.

I am not sure it is Spaces’s problem or not. Next time when this happens, could you please do
(1)Spaces- >Note->Copy Title
(2)Spaces ->Note->Copy Link to Note

and post the title and link here?

Thank you

@praj , I just reproduced the problem.

For most notes, the url looks like this:

And Hookmark works fine with it.

For some note, “Copy Link to Note” get a url like:
spaces://x-callback-url/open-note?id=Welcome to Spaces

The url is not probably encoded. In this case, the space in the URL is not encoded as %20. Hookmark can’t work with it.

Thank you

1 Like

I’ve informed the Spaces app developer about this thread here. Hopefully they can improve upon the integration to Hookmark.

Thank you so much for your support on this!