|
|
@ -1,30 +1,14 @@
|
|
|
|
(local {: mash : smash : modal-bind} (require :hotkey))
|
|
|
|
(local {: mash : smash : modal-bind} (require :hotkey))
|
|
|
|
|
|
|
|
|
|
|
|
(local {: application
|
|
|
|
(local log (hs.logger.new :log :info))
|
|
|
|
: caffeinate
|
|
|
|
(set hs.logger.defaultLogLevel :info)
|
|
|
|
: eventtap
|
|
|
|
|
|
|
|
: execute
|
|
|
|
|
|
|
|
: fs
|
|
|
|
|
|
|
|
: hotkey
|
|
|
|
|
|
|
|
: http
|
|
|
|
|
|
|
|
: json
|
|
|
|
|
|
|
|
: logger
|
|
|
|
|
|
|
|
: loadSpoon
|
|
|
|
|
|
|
|
: notify
|
|
|
|
|
|
|
|
: pasteboard
|
|
|
|
|
|
|
|
: uielement
|
|
|
|
|
|
|
|
: usb} hs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(local log (logger.new :log :info))
|
|
|
|
|
|
|
|
(set logger.defaultLogLevel :info)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(set hs.window.animationDuration 0.0)
|
|
|
|
(set hs.window.animationDuration 0.0)
|
|
|
|
(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
|
|
|
|
|
|
|
|
|
|
|
|
;; fnlfmt: skip
|
|
|
|
;; fnlfmt: skip
|
|
|
|
(let [{: MiroWindowsManager} spoon]
|
|
|
|
(spoon.MiroWindowsManager:bindHotkeys {:up [mash :k]
|
|
|
|
(MiroWindowsManager:bindHotkeys {:up [mash :k]
|
|
|
|
|
|
|
|
:left [mash :h]
|
|
|
|
:left [mash :h]
|
|
|
|
:down [mash :j]
|
|
|
|
:down [mash :j]
|
|
|
|
:right [mash :l]
|
|
|
|
:right [mash :l]
|
|
|
@ -32,49 +16,48 @@
|
|
|
|
;; :center [mash "c"]
|
|
|
|
;; :center [mash "c"]
|
|
|
|
;; :move [smash "m"]
|
|
|
|
;; :move [smash "m"]
|
|
|
|
;; :resize [mash "d"]
|
|
|
|
;; :resize [mash "d"]
|
|
|
|
}))
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
;; debugging
|
|
|
|
;; debugging
|
|
|
|
;; (hotkey.bind mash "d" (fn [] (hs.dialog.blockAlert "message" "text" "one" "two")))
|
|
|
|
;; (hs.hotkey.bind mash "d" (fn [] (hs.dialog.blockAlert "message" "text" "one" "two")))
|
|
|
|
;; (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
|
|
|
|
(hotkey.bind [:cmd :alt] :v #(eventtap.keyStrokes (pasteboard.getContents)))
|
|
|
|
(hs.hotkey.bind [:cmd :alt] :v
|
|
|
|
|
|
|
|
#(hs.eventtap.keyStrokes (hs.pasteboard.getContents)))
|
|
|
|
(hotkey.bind mash :e
|
|
|
|
|
|
|
|
#(let [app (application.frontmostApplication)
|
|
|
|
(hs.hotkey.bind mash :e
|
|
|
|
prev-pasteboard (pasteboard.getContents)
|
|
|
|
#(let [app (hs.application.frontmostApplication)
|
|
|
|
e (uielement.focusedElement)
|
|
|
|
prev-pasteboard (hs.pasteboard.getContents)
|
|
|
|
text (if e (e:selectedText)
|
|
|
|
e (hs.uielement.focusedElement)
|
|
|
|
(do
|
|
|
|
text (if e (e:selectedText)
|
|
|
|
(eventtap.keyStroke [:cmd] :c)
|
|
|
|
(do
|
|
|
|
(pasteboard.getContents)))
|
|
|
|
(hs.eventtap.keyStroke [:cmd] :c)
|
|
|
|
date (execute "date -Iseconds -u | tr -d '\n'")
|
|
|
|
(hs.pasteboard.getContents)))
|
|
|
|
file (.. "~/.quickcursor." date)]
|
|
|
|
date (hs.execute "date -Iseconds -u | tr -d '\n'")
|
|
|
|
(pasteboard.setContents text)
|
|
|
|
file (.. "~/.quickcursor." date)]
|
|
|
|
(execute (.. "pbpaste > " file))
|
|
|
|
(hs.pasteboard.setContents text)
|
|
|
|
(execute (.. "/opt/homebrew/bin/neovide --nofork " file))
|
|
|
|
(hs.execute (.. "pbpaste > " file))
|
|
|
|
(execute (.. "pbcopy < " file))
|
|
|
|
(hs.execute (.. "/opt/homebrew/bin/neovide --nofork " file))
|
|
|
|
(app:setFrontmost)
|
|
|
|
(hs.execute (.. "pbcopy < " file))
|
|
|
|
(eventtap.keyStroke [:cmd] :v)
|
|
|
|
(app:setFrontmost)
|
|
|
|
(execute (.. "rm " file))
|
|
|
|
(hs.eventtap.keyStroke [:cmd] :v)
|
|
|
|
(pasteboard.setContents prev-pasteboard)))
|
|
|
|
(hs.execute (.. "rm " file))
|
|
|
|
|
|
|
|
(hs.pasteboard.setContents prev-pasteboard)))
|
|
|
|
(hotkey.bind mash :t #(execute :/opt/homebrew/bin/alacritty))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(fn linkify []
|
|
|
|
(fn linkify []
|
|
|
|
(let [app (application.frontmostApplication)
|
|
|
|
(let [app (hs.application.frontmostApplication)
|
|
|
|
prev-pasteboard (pasteboard.getContents)
|
|
|
|
prev-pasteboard (hs.pasteboard.getContents)
|
|
|
|
e (uielement.focusedElement)
|
|
|
|
e (hs.uielement.focusedElement)
|
|
|
|
text (if e (e:selectedText)
|
|
|
|
text (if e (e:selectedText)
|
|
|
|
(do
|
|
|
|
(do
|
|
|
|
(eventtap.keyStroke [:cmd] :c)
|
|
|
|
(hs.eventtap.keyStroke [:cmd] :c)
|
|
|
|
(pasteboard.getContents)))
|
|
|
|
(hs.pasteboard.getContents)))
|
|
|
|
link (.. "[" text "]" "(" prev-pasteboard ")")]
|
|
|
|
link (.. "[" text "]" "(" prev-pasteboard ")")]
|
|
|
|
(pasteboard.setContents link)
|
|
|
|
(hs.pasteboard.setContents link)
|
|
|
|
(app:setFrontmost)
|
|
|
|
(app:setFrontmost)
|
|
|
|
(eventtap.keyStroke [:cmd] :v)
|
|
|
|
(hs.eventtap.keyStroke [:cmd] :v)
|
|
|
|
(pasteboard.setContents prev-pasteboard)))
|
|
|
|
(hs.pasteboard.setContents prev-pasteboard)))
|
|
|
|
|
|
|
|
|
|
|
|
(modal-bind mash "," nil [[mash :l nil linkify]])
|
|
|
|
(modal-bind mash "," nil [[mash :l nil linkify]])
|
|
|
|
|
|
|
|
|
|
|
@ -89,14 +72,14 @@
|
|
|
|
(fn update-key-light-air [on?]
|
|
|
|
(fn update-key-light-air [on?]
|
|
|
|
(let [url "http://elgato-key-light-air-5c9e.local:9123/elgato/lights"
|
|
|
|
(let [url "http://elgato-key-light-air-5c9e.local:9123/elgato/lights"
|
|
|
|
on (if on? 1 0)
|
|
|
|
on (if on? 1 0)
|
|
|
|
data (json.encode {:lights [{: on}]})]
|
|
|
|
data (hs.json.encode {:lights [{: on}]})]
|
|
|
|
(http.doRequest url :PUT data)))
|
|
|
|
(hs.http.doRequest url :PUT data)))
|
|
|
|
|
|
|
|
|
|
|
|
(fn docked? []
|
|
|
|
(fn docked? []
|
|
|
|
(accumulate [docked? false _ v (pairs (usb.attachedDevices)) &until docked?]
|
|
|
|
(accumulate [docked? false _ v (pairs (hs.usb.attachedDevices)) &until docked?]
|
|
|
|
(or docked? (= v.productName "CalDigit Thunderbolt 3 Audio"))))
|
|
|
|
(or docked? (= v.productName "CalDigit Thunderbolt 3 Audio"))))
|
|
|
|
|
|
|
|
|
|
|
|
(local key-light-air-watcher (let [{: watcher} caffeinate
|
|
|
|
(local key-light-air-watcher (let [{: watcher} hs.caffeinate
|
|
|
|
w (watcher.new #(when (docked?)
|
|
|
|
w (watcher.new #(when (docked?)
|
|
|
|
(match $1
|
|
|
|
(match $1
|
|
|
|
watcher.screensDidLock (update-key-light-air false)
|
|
|
|
watcher.screensDidLock (update-key-light-air false)
|
|
|
@ -105,7 +88,7 @@
|
|
|
|
watcher.screensDidWake (update-key-light-air true))))]
|
|
|
|
watcher.screensDidWake (update-key-light-air true))))]
|
|
|
|
(w:start)))
|
|
|
|
(w:start)))
|
|
|
|
|
|
|
|
|
|
|
|
; (local usb-watcher (: (usb.watcher.new #(let [{: eventType : productName} $1]
|
|
|
|
; (local usb-watcher (: (hs.usb.watcher.new #(let [{: eventType : productName} $1]
|
|
|
|
; (when (= productName
|
|
|
|
; (when (= productName
|
|
|
|
; "CalDigit Thunderbolt 3 Audio")
|
|
|
|
; "CalDigit Thunderbolt 3 Audio")
|
|
|
|
; (match eventType
|
|
|
|
; (match eventType
|
|
|
@ -119,13 +102,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
;;; Spoons
|
|
|
|
;;; Spoons
|
|
|
|
|
|
|
|
|
|
|
|
(: (loadSpoon :ReloadConfiguration) :start)
|
|
|
|
(: (hs.loadSpoon :ReloadConfiguration) :start)
|
|
|
|
|
|
|
|
|
|
|
|
;; Local overrides
|
|
|
|
;; Local overrides
|
|
|
|
(when (fs.attributes :local.fnl)
|
|
|
|
(when (hs.fs.attributes :local.fnl)
|
|
|
|
(require :local))
|
|
|
|
(require :local))
|
|
|
|
|
|
|
|
|
|
|
|
(: (notify.new {:title :Hammerspoon
|
|
|
|
(: (hs.notify.new {:title :Hammerspoon
|
|
|
|
:informativeText "Config loaded"
|
|
|
|
:informativeText "Config loaded"
|
|
|
|
:withdrawAfter 2}) :send)
|
|
|
|
:withdrawAfter 2}) :send)
|
|
|
|
|
|
|
|
|
|
|
|