Hook + Logseq = ❤️

trying to think how to get this done as well

2 Likes

I don’t think Logseq has an API for this, but perhaps they would be amenable to providing it:

3 Likes

:pray: Thank you for your reply, I will try to contact the developer of Logseq, maybe they will support an API for this in the future.

1 Like

just checking if there is any update on this

1 Like

Hi, I have contacted with the developer of Logseq, they will add support for Hook, maybe we will see the integration of hook and Logseq later.
Thank you for work, they say Hook has contacted with them on Twitter, but do not know how to achieve it, now they start do some work with it.
Screen Shot 2022-07-08 at 22.52.54

1 Like

@LucB The developer of Logseq has added the x-callback-url getCurrentURL

1 Like

Thank you for letting us know! I checked last night build and it seems the feature is not there yet. We will work on the integration with Logseq once this feature is available.

2 Likes

@mzwlevi, any news regarding ETAs for that? Or maybe it’s in already?

I also wonder if this feature will ever come to logseq

There’s a Twitter thread on the subject if you’d like to join the discussion there. I wrote:

A logseq rep asked on Twitter

what can we do to help you become an even better coder?

I answered

Make your app linkable. That’s what leading Mac developers have done: Manifesto for Ubiquitous Linking
cf. Information for Developers to Make Their Apps Linkable (API Requirements for Compatibility with Hook) – Hook

The rep seemed to think that linkability just entails having a UI for linking, as he wrote:

@LucCogZest We already have a URI scheme with logseq:// You can right-click a block or page title to get its link." / Twitter

I replied that

the manifesto calls for automation to obtain the link and title of the resource https://linkingmanifesto.org/technical-requirements/…. Any form of automation will do. The manifesto is agnostic about the API language.

Please feel free to chime in there.

FYI

I just wrote this, if there is any misunderstanding, please help explain.
If anyone sees this message, please click on the link above and click vote in the upper left corner, this will help Logseq pay more attention to this feature request.

1 Like

Welcome to the Hookmark Forum, @hexinzhe, and thank you for this. That helps. I have added a comment there.

it is sometimes useful to reference the Manifesto for Ubiquitous Linking for devs and their community to appreciate the full context. I’ll mention that next.

I am not a good applescript programmer, but I wrote this to make hookmark work with logseq.

You must replace MYGRAPHNAME with the name of your logseq graph (which you can see when you copy a block URL). You must also add :editor/copy-embed "mod+shift+c" to :shortcuts in config.edn. If there is a keyboard shortcut for copying block URL this would not be necessary, but there isn’t, so I have to change the block reference to a URL myself.

set savedClipboard to the clipboard
set the clipboard to ""
tell application "Logseq" to activate
tell application "System Events"
	keystroke "c" using {command down, shift down}
	delay 0.05
	repeat 10 times
		try
			set blockRef to the clipboard
			if blockRef is not equal to "" then
				exit repeat
			end if
			keystroke "c" using {shift down, command down}
		end try
		delay 0.05
	end repeat
	set blockUrl to "logseq://graph/MYGRAPHNAME?block-id=" & characters 11 thru -5 of blockRef as string
	keystroke "a" using {command down}
	delay 0.05
	keystroke "c" using {command down}
	delay 0.05
	set blockContents to the clipboard
	set blockLength to (get length of (blockContents as text))
	if blockLength is less than 32 then
		set linkTitle to blockContents as string
	else
		set linkTitle to (characters 1 thru 32 of blockContents as string) & "..."
	end if
end tell
set the clipboard to savedClipboard
return "[" & linkTitle & "](" & blockUrl & ")"
3 Likes

Awesome! thanks for sharing. We’ll have a look. We want to support logseq ASAP.

2 Likes

I tried to paste this into the script gallery in Hookmark for Logseq under the Get Adress, but I couldn’t get it to work. How do you use this script?

Welcome to the Hookmark Forum , @Kullenej . We will publish a tweak with additional instructions very soon. Meanwhile, we urge anyone who wants Logseq automation to contact the Logseq devs to ask them to spend a few minutes to add an API for linking, otherwise their software is in a walled-garden. Or some may wish to contribute directly if you’re a dev and user of that software. Cf Manifesto for Ubiquitous Linking. Obsidian has extensive automation for linking: https://hookproductivity.com/help/integration/using-hook-with-obsidian/ .

1 Like

The script our user provided. I did a small change by creating a variable for graph name.

#change YourGraphName to your graph's name
set graphName to "YourGraphName"

set savedClipboard to the clipboard
delay 0.05
set the clipboard to ""
delay 0.05
tell application "Logseq" to activate
tell application "System Events"
	keystroke "c" using {command down, shift down}
	delay 0.05
	repeat 10 times
		try
			set blockRef to the clipboard
			if blockRef is not equal to "" then
				exit repeat
			end if
			keystroke "c" using {shift down, command down}
		end try
		delay 0.05
	end repeat
	set blockUrl to "logseq://graph/" & graphName & "?block-id=" & characters 11 thru -5 of blockRef as string
	keystroke "a" using {command down}
	delay 0.05
	keystroke "c" using {command down}
	delay 0.05
	set blockContents to the clipboard
	delay 0.05
	set blockLength to (get length of (blockContents as text))
	if blockLength is less than 32 then
		set linkTitle to blockContents as string
	else
		set linkTitle to (characters 1 thru 32 of blockContents as string) & "..."
	end if
end tell
set the clipboard to savedClipboard
return "[" & linkTitle & "](" & blockUrl & ")"

In order to make this script work, In Logseq settings > Edit Config.edn, add the following line:

:editor/copy-embed “mod+shift+c”
to
:shortcuts {
}

After edit, it should look like this:
:shortcuts {
:editor/copy-embed “mod+shift+c”
}

Please let us know your experience with it.

2 Likes

Thank you! I’m actively engaging the Logseq forum for this as well.
But unfortunately, I can’t get the script to work.
Here is how it looks in Hookmark:

I have also restarted both apps, but no luck!

Thanks!!

And here is my Logseq config.edn:

You put the shortcut in the comments(they have green color). I did the same thing in the beginning. Please put the shortcut in shortcuts{} with red color. Also before invoke Hookmark, please put the mouse cursor in one of the blocks.

1 Like