- Install Hammerspoon
- Install SpoonInstall (unzip and click to install)
- Move the contents of
alwaysApp.luaorappOrWebDialog.luato~/.hammerspoon/init.lua - Set Hammerspoon as default web browser in macOS preferences -> General
Last active
June 2, 2020 14:29
-
-
Save jellea/95fbff7e8fd820b78f18250d57ace1b9 to your computer and use it in GitHub Desktop.
Say, a colleague passes you a Figma link, you click it and surprisingly the browser opens, while you have the desktop app installed! You *sigh* and install this script script which adds a question if you want to open web or desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defaultBrowser = "org.mozilla.Firefox" | |
| --defaultBrowser = "com.google.Chrome" | |
| hs.loadSpoon("SpoonInstall") | |
| Install=spoon.SpoonInstall | |
| Install:andUse("URLDispatcher", | |
| { | |
| config = { | |
| url_patterns = { | |
| { "https?://www.figma.com", "com.figma.Desktop" }, | |
| { "https?://www.notion.so", "notion.id" }, | |
| }, | |
| default_handler = defaultBrowser | |
| }, | |
| start = true | |
| } | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defaultBrowser = "org.mozilla.Firefox" | |
| --defaultBrowser = "com.google.Chrome" | |
| hs.loadSpoon("SpoonInstall") | |
| Install=spoon.SpoonInstall | |
| function openUrl(appBundleID,url,choice) | |
| if choice=="Browser" then | |
| appBundleID = defaultBrowser | |
| end | |
| hs.application.launchOrFocusByBundleID(appBundleID) | |
| hs.urlevent.openURLWithBundle(url, appBundleID) | |
| end | |
| function webOrDesktop (appBundleID,appName,url) | |
| openFn = hs.fnutils.partial(openUrl, appBundleID, url) | |
| hs.dialog.alert(100,100,openFn,"How would you like to open this "..appName.." link?", "", "Desktop App", "Browser") | |
| 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 | |
| } | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment