Skip to content

Instantly share code, notes, and snippets.

@jaawerth
Last active December 4, 2023 09:37
Show Gist options
  • Save jaawerth/db68fcd3e571e4180bbaf153f7e258a5 to your computer and use it in GitHub Desktop.
Save jaawerth/db68fcd3e571e4180bbaf153f7e258a5 to your computer and use it in GitHub Desktop.
hammerspoon (Macos automation) using fennel
; gist doesn't know what fennel is so let's say clj
; vi: ft=clojure
(set hs.logger.defaultLogLevel "info")
(local {:application app :hotkey hotkey} hs)
; use the SpoonInstall Spoon easy installing+loading of Spoons
(hs.loadSpoon :SpoonInstall)
(local install (. spoon :SpoonInstall))
; for window sizing, use the WIndowHalfsAndThirds Spoon until I can write something custom
(: install :andUse :WindowHalfsAndThirds)
; just bind the default hotkeys for now
(: spoon.WindowHalfsAndThirds :bindHotkeys
(. spoon :WindowHalfsAndThirds :defaultHotkeys))
; launch/focus/activate kitty terminal
(hotkey.bind [:cmd :ctrl] :t
"😾 terminal"
(partial app.open "kitty"))
local fennel = require"fennel"
-- allow requiring of fennel modules
table.insert(package.loaders or package.searchers, fennel.searcher)
fennel.dofile("init.fnl", { allowedGlobals = false })
@dconnett-splunk
Copy link

I needed to perform a minor correction to this code to get it working:

local fennel = require("fennel") -- Fixed: pass the string "fennel"

-- allow requiring of fennel modules
table.insert(package.loaders or package.searchers, fennel.searcher)

fennel.dofile("init.fnl", { allowedGlobals = false })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment