|
|
@ -48,16 +48,25 @@
|
|
|
|
;; https://stackoverflow.com/questions/39464668/how-to-get-bundle-id-of-mac-application
|
|
|
|
;; https://stackoverflow.com/questions/39464668/how-to-get-bundle-id-of-mac-application
|
|
|
|
;; osascript -e 'id of app "SomeApp"'
|
|
|
|
;; osascript -e 'id of app "SomeApp"'
|
|
|
|
;; mdls -name kMDItemCFBundleIdentifier -r SomeApp.app
|
|
|
|
;; mdls -name kMDItemCFBundleIdentifier -r SomeApp.app
|
|
|
|
|
|
|
|
(fn bundleIDForURL [url]
|
|
|
|
|
|
|
|
(let [matchers {
|
|
|
|
|
|
|
|
".*[.]zoom.us/j/%d+" "us.zoom.xos"
|
|
|
|
|
|
|
|
".*[.]discnw.org/" "com.apple.Safari"
|
|
|
|
|
|
|
|
"squareup.com/" "com.apple.Safari" }]
|
|
|
|
|
|
|
|
(do
|
|
|
|
|
|
|
|
(var bundleID nil)
|
|
|
|
|
|
|
|
(each [key value (pairs matchers) :until bundleID]
|
|
|
|
|
|
|
|
(if (string.find url (.. "^https://" key))
|
|
|
|
|
|
|
|
(set bundleID value)))
|
|
|
|
|
|
|
|
(or bundleID "org.mozilla.firefoxdeveloperedition"))))
|
|
|
|
|
|
|
|
|
|
|
|
(set hs.urlevent.httpCallback
|
|
|
|
(set hs.urlevent.httpCallback
|
|
|
|
(fn [scheme host params fullURL]
|
|
|
|
(fn [scheme host params fullURL]
|
|
|
|
(let [command (.. "curl -Ls -o /dev/null -w %{url_effective} " fullURL)
|
|
|
|
(let [command (.. "curl -Ls -o /dev/null -w %{url_effective} " fullURL)
|
|
|
|
handle (io.popen command)
|
|
|
|
handle (io.popen command)
|
|
|
|
url (handle:read "*a")]
|
|
|
|
url (handle:read "*a")
|
|
|
|
(if (string.find url "^https?://.*[.]zoom.us/j/%d+")
|
|
|
|
bundleID (bundleIDForURL url)]
|
|
|
|
(hs.urlevent.openURLWithBundle fullURL "us.zoom.xos")
|
|
|
|
(hs.urlevent.openURLWithBundle fullURL bundleID))))
|
|
|
|
(string.find url "^https?://.*[.]discnw.org/")
|
|
|
|
|
|
|
|
(hs.urlevent.openURLWithBundle fullURL "com.apple.Safari")
|
|
|
|
|
|
|
|
(hs.urlevent.openURLWithBundle fullURL "org.mozilla.firefoxdeveloperedition")))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Spoons
|
|
|
|
;; Spoons
|
|
|
|
|
|
|
|
|
|
|
|