|
defaultBrowser = "org.mozilla.Firefox" |
|
--Remove hypens below to set other browser as a default |
|
--defaultBrowser = "com.google.Chrome" |
|
--defaultBrowser = "com.apple.Safari" |
|
|
|
defaultBrowserName = string.match(defaultBrowser, '%a+$') |
|
|
|
hs.loadSpoon("SpoonInstall") |
|
Install=spoon.SpoonInstall |
|
|
|
function openUrl(appBundleID,url,choice) |
|
if choice==defaultBrowserName then |
|
appBundleID = defaultBrowser |
|
-- Workaround: Notion share links can contain the company name, which the desktop app can't open. |
|
elseif string.find(url, "notion.so/") then |
|
url = string.gsub(url, "/pitch", "") |
|
end |
|
|
|
hs.application.launchOrFocusByBundleID(appBundleID) |
|
hs.urlevent.openURLWithBundle(url, appBundleID) |
|
end |
|
|
|
function webOrDesktop(appBundleID,appName,url) |
|
openFn = hs.fnutils.partial(openUrl, appBundleID, url) |
|
mousePos = hs.mouse.getAbsolutePosition() |
|
hs.dialog.alert(mousePos.x,mousePos.y,openFn,"How to open this "..appName.." link?", "", appName.." App", defaultBrowserName) |
|
end |
|
|
|
Install:andUse("URLDispatcher", |
|
{ |
|
config = { |
|
url_patterns = { |
|
{ "https?://www.figma.com", nil, hs.fnutils.partial(webOrDesktop, "com.figma.Desktop", "Figma") }, |
|
{ "https?://www.notion.so", nil, hs.fnutils.partial(webOrDesktop, "notion.id", "Notion")}, |
|
}, |
|
default_handler = defaultBrowser |
|
}, |
|
start = true |
|
} |
|
) |