|
|
@ -1,22 +1,23 @@
|
|
|
|
(local log (hs.logger.new "log" "info"))
|
|
|
|
(local log (hs.logger.new :log :info))
|
|
|
|
(set hs.logger.defaultLogLevel "info")
|
|
|
|
(set hs.logger.defaultLogLevel :info)
|
|
|
|
|
|
|
|
|
|
|
|
(local mash [:cmd :alt :ctrl])
|
|
|
|
(local mash [:cmd :alt :ctrl])
|
|
|
|
(local smash [:cmd :alt :ctrl :shift])
|
|
|
|
(local smash [:cmd :alt :ctrl :shift])
|
|
|
|
|
|
|
|
|
|
|
|
(set hs.window.animationDuration 0.0)
|
|
|
|
(set hs.window.animationDuration 0.0)
|
|
|
|
(hs.loadSpoon "MiroWindowsManager")
|
|
|
|
(hs.loadSpoon :MiroWindowsManager)
|
|
|
|
;; (set spoon.MiroWindowsManager.fullScreenSizes [1 (/ 4 3) 2]) ;; only fullscreen
|
|
|
|
;; (set spoon.MiroWindowsManager.fullScreenSizes [1 (/ 4 3) 2]) ; only fullscreen
|
|
|
|
(spoon.MiroWindowsManager:bindHotkeys {
|
|
|
|
|
|
|
|
:up [ mash "k" ]
|
|
|
|
;; fnlfmt: skip
|
|
|
|
:left [ mash "h" ]
|
|
|
|
(spoon.MiroWindowsManager:bindHotkeys {:up [mash :k]
|
|
|
|
:down [ mash "j" ]
|
|
|
|
:left [mash :h]
|
|
|
|
:right [ mash "l" ]
|
|
|
|
:down [mash :j]
|
|
|
|
:fullscreen [ mash "m" ]
|
|
|
|
:right [mash :l]
|
|
|
|
;; :center [ mash "c" ]
|
|
|
|
:fullscreen [mash :m]
|
|
|
|
;; :move [ smash "m" ]
|
|
|
|
;; :center [mash "c"]
|
|
|
|
;; :resize [ mash "d" ]
|
|
|
|
;; :move [smash "m"]
|
|
|
|
})
|
|
|
|
;; :resize [mash "d"]
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
;; debugging
|
|
|
|
;; debugging
|
|
|
|
;; (hs.hotkey.bind mash "d" (fn []))
|
|
|
|
;; (hs.hotkey.bind mash "d" (fn []))
|
|
|
@ -24,70 +25,74 @@
|
|
|
|
;; (hs.hotkey.bind mash "d" (fn [] (hs.dialog.alert 100 100 (fn [] ) "message" "text" "one" "two")))
|
|
|
|
;; (hs.hotkey.bind mash "d" (fn [] (hs.dialog.alert 100 100 (fn [] ) "message" "text" "one" "two")))
|
|
|
|
|
|
|
|
|
|
|
|
;; defeat paste blocking
|
|
|
|
;; defeat paste blocking
|
|
|
|
(hs.hotkey.bind [:cmd :alt] "v" (fn [] (hs.eventtap.keyStrokes (hs.pasteboard.getContents))))
|
|
|
|
(hs.hotkey.bind [:cmd :alt] :v
|
|
|
|
|
|
|
|
#(hs.eventtap.keyStrokes (hs.pasteboard.getContents)))
|
|
|
|
(hs.hotkey.bind mash "e" (fn []
|
|
|
|
|
|
|
|
(let [app (hs.application.frontmostApplication)
|
|
|
|
(hs.hotkey.bind mash :e
|
|
|
|
prev-pasteboard (hs.pasteboard.getContents)
|
|
|
|
#(let [app (hs.application.frontmostApplication)
|
|
|
|
e (hs.uielement.focusedElement)
|
|
|
|
prev-pasteboard (hs.pasteboard.getContents)
|
|
|
|
text (if e (e:selectedText)
|
|
|
|
e (hs.uielement.focusedElement)
|
|
|
|
(do
|
|
|
|
text (if e (e:selectedText)
|
|
|
|
(hs.eventtap.keyStroke [:cmd] "c")
|
|
|
|
(do
|
|
|
|
(hs.pasteboard.getContents)))
|
|
|
|
(hs.eventtap.keyStroke [:cmd] :c)
|
|
|
|
date (hs.execute "date -Iseconds -u | tr -d '\n'")
|
|
|
|
(hs.pasteboard.getContents)))
|
|
|
|
file (.. "~/.quickcursor." date)]
|
|
|
|
date (hs.execute "date -Iseconds -u | tr -d '\n'")
|
|
|
|
(hs.pasteboard.setContents text)
|
|
|
|
file (.. "~/.quickcursor." date)]
|
|
|
|
(hs.execute (.. "pbpaste > " file))
|
|
|
|
(hs.pasteboard.setContents text)
|
|
|
|
(hs.execute (.. "/opt/homebrew/bin/mvim --nofork " file))
|
|
|
|
(hs.execute (.. "pbpaste > " file))
|
|
|
|
(hs.execute (.. "pbcopy < " file))
|
|
|
|
(hs.execute (.. "/opt/homebrew/bin/mvim --nofork " file))
|
|
|
|
(app:setFrontmost)
|
|
|
|
(hs.execute (.. "pbcopy < " file))
|
|
|
|
(hs.eventtap.keyStroke [:cmd] "v")
|
|
|
|
(app:setFrontmost)
|
|
|
|
(hs.execute (.. "rm " file))
|
|
|
|
(hs.eventtap.keyStroke [:cmd] :v)
|
|
|
|
(hs.pasteboard.setContents prev-pasteboard))))
|
|
|
|
(hs.execute (.. "rm " file))
|
|
|
|
|
|
|
|
(hs.pasteboard.setContents prev-pasteboard)))
|
|
|
|
|
|
|
|
|
|
|
|
;; 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; fnlfmt: skip
|
|
|
|
|
|
|
|
(local matchers {".*[.]zoom.us/j/%d+" :us.zoom.xos
|
|
|
|
|
|
|
|
".*[.]discnw.org/" :com.apple.Safari
|
|
|
|
|
|
|
|
:squareup.com/ :com.apple.Safari})
|
|
|
|
|
|
|
|
|
|
|
|
(fn bundleIDForURL [url]
|
|
|
|
(fn bundleIDForURL [url]
|
|
|
|
(let [matchers {
|
|
|
|
(var bundleID nil)
|
|
|
|
".*[.]zoom.us/j/%d+" "us.zoom.xos"
|
|
|
|
(each [key value (pairs matchers) :until bundleID]
|
|
|
|
".*[.]discnw.org/" "com.apple.Safari"
|
|
|
|
(if (string.find url (.. "^https://" key))
|
|
|
|
"squareup.com/" "com.apple.Safari" }]
|
|
|
|
(set bundleID value)))
|
|
|
|
(do
|
|
|
|
(or bundleID :org.mozilla.firefoxdeveloperedition))
|
|
|
|
(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 url]
|
|
|
|
(let [command (.. "curl -Ls -o /dev/null -w %{url_effective} " fullURL)
|
|
|
|
(let [run #(: (io.popen (.. $1 " \"" $2 "\"")) :read :*a)
|
|
|
|
handle (io.popen command)
|
|
|
|
de-utm (partial run "~/.dotfiles/bin/de-utm")
|
|
|
|
url (handle:read "*a")
|
|
|
|
redirect (partial run "curl -Ls -o /dev/null -w %{url_effective}")
|
|
|
|
bundleID (bundleIDForURL url)]
|
|
|
|
final-url (->> url
|
|
|
|
(hs.urlevent.openURLWithBundle fullURL bundleID))))
|
|
|
|
(de-utm)
|
|
|
|
|
|
|
|
(redirect)
|
|
|
|
;; Spoons
|
|
|
|
(de-utm))
|
|
|
|
|
|
|
|
bundleID (bundleIDForURL final-url)]
|
|
|
|
(hs.loadSpoon "ReloadConfiguration")
|
|
|
|
(hs.urlevent.openURLWithBundle final-url bundleID))))
|
|
|
|
(spoon.ReloadConfiguration:start)
|
|
|
|
|
|
|
|
|
|
|
|
;;; Spoons
|
|
|
|
(hs.loadSpoon "Quitter")
|
|
|
|
|
|
|
|
(set spoon.Quitter.quitAppsAfter {
|
|
|
|
(: (hs.loadSpoon :ReloadConfiguration) :start)
|
|
|
|
:Discord 300
|
|
|
|
|
|
|
|
:MailMate 600
|
|
|
|
(hs.loadSpoon :Quitter)
|
|
|
|
:Messages 300
|
|
|
|
|
|
|
|
:Reeder 600
|
|
|
|
;; fnlfmt: skip
|
|
|
|
:Slack 300
|
|
|
|
(set spoon.Quitter.quitAppsAfter
|
|
|
|
:Telegram 300
|
|
|
|
{:Discord 300
|
|
|
|
:Twitterrific 300
|
|
|
|
:MailMate 600
|
|
|
|
})
|
|
|
|
:Messages 300
|
|
|
|
|
|
|
|
:Reeder 600
|
|
|
|
|
|
|
|
:Slack 300
|
|
|
|
|
|
|
|
:Telegram 300
|
|
|
|
|
|
|
|
:Twitterrific 300})
|
|
|
|
|
|
|
|
|
|
|
|
(spoon.Quitter:start)
|
|
|
|
(spoon.Quitter:start)
|
|
|
|
|
|
|
|
|
|
|
|
(let [n (hs.notify.new {
|
|
|
|
(: (hs.notify.new {:title :Hammerspoon
|
|
|
|
:title "Hammerspoon"
|
|
|
|
:informativeText "Config loaded"
|
|
|
|
:informativeText "Config loaded"
|
|
|
|
:withdrawAfter 2}) :send)
|
|
|
|
:withdrawAfter 2
|
|
|
|
|
|
|
|
})]
|
|
|
|
|
|
|
|
(n:send))
|
|
|
|
|
|
|
|