Integration script for Linear

Hi!

I’m exploring Hookmark specifically for linking items in Linear to other apps, particularly Obsidian.

I mostly use the Linear desktop app, on Mac.

I’ve come up with the following script for “Get address”. It relies on UI automation as I haven’t found another way to discover the current open item in Linear. (I’ve started a thread on their Slack forum)

delay 0.1
set the clipboard to ""
delay 0.2

tell application "System Events" to tell process "Linear"
    keystroke "," using {command down, shift down}
    delay 0.5
    
    repeat 50 times -- poll clipboard for ~2.5 seconds
        try
            if (the clipboard) is not equal to "" then
                exit repeat
            end if
        end try
        delay 0.05
    end repeat
    
end tell
set issueUrl to the clipboard

-- Check if the Linear application is running
set useDesktopURL to false
tell application "System Events"
    set appList to (name of every process)
    if appList contains "Linear" then
        set useDesktopURL to true
    end if
end tell

if useDesktopURL then
    -- Extract team and issue ID from the web URL
    set AppleScript's text item delimiters to "/"
    set urlComponents to text items of issueUrl
    set team to item 4 of urlComponents
    set issueID to item 6 of urlComponents

    -- Format the desktop URL
    set desktopIssueUrl to "linear://" & team & "/issue/" & issueID
end if

tell application "System Events"
    tell process "Linear"
        set issueTitle to name of window 1
    end tell
end tell

if useDesktopURL then
    return "[" & issueTitle & "](" & desktopIssueUrl & ")"
else
    return "[" & issueTitle & "](" & issueUrl & ")"
end if

I hope this helps someone. Feedback and complete rewrites :grinning: welcome.

1 Like

Thank you very much for the script, @man8louis .

I will take the following script out because the get Address script is only called when the Linear Desktop app is running. Correct me if this is wrong. I am not familiar Linear.

Indeed, thank you. It seems I didn’t quite think that through.

Linear has made some changes to how the window title is displayed which break the existing integration script. I’ve updated it to use the built-in shortcuts to get ticket and project titles, as well as to properly format project links:

set the clipboard to ""
delay 0.2

-- Get project or ticket title
tell application "System Events" to tell process "Linear"
	keystroke "'" using {command down, shift down}
	delay 0.1
	repeat 50 times -- poll clipboard for ~2.5 seconds
		try
			if (the clipboard) is not equal to "" then
				exit repeat
			end if
		end try
		delay 0.05
	end repeat
end tell
set itemTitle to the clipboard

-- Get 
tell application "System Events" to tell process "Linear"
	keystroke "C" using {command down, shift down}
	delay 0.1
	repeat 50 times -- poll clipboard for ~2.5 seconds
		try
			if (the clipboard) is not equal to "" then
				exit repeat
			end if
		end try
		delay 0.05
	end repeat
end tell
set itemUrl to the clipboard

-- Extract team and item ID from the web URL
set AppleScript's text item delimiters to "/"
set urlComponents to text items of itemUrl
set team to item 4 of urlComponents
set itemKind to item 5 of urlComponents
set itemID to item 6 of urlComponents

-- Format the desktop URL
set desktopItemUrl to "linear://" & team & "/" & itemKind & "/" & itemID

return "[" & itemTitle & "](" & desktopItemUrl & ")"

Thank you, @ndpi .

I just tried Linear Version 1.27.5 (2412044qwx4cqqw) and it seems to be working fine. What’s your Linear’s version number?

I’m on Version 1.27.5 (2412044qwx4cqqw) as well, on MacOS 15.1.1 (24B91). Not sure why there’s a difference in behavior, but my window titles aren’t updating with the issue title. My updates to the script use the key bindings provided by Linear instead of relying on “secondary” behavior — which is probably worthwhile regardless in order to make the script a little bit more robust.