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