Skip to content

Instantly share code, notes, and snippets.

@catskull
Last active August 3, 2021 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save catskull/362f9578f10a53b3debb9ac51aafcf07 to your computer and use it in GitHub Desktop.
Save catskull/362f9578f10a53b3debb9ac51aafcf07 to your computer and use it in GitHub Desktop.
Hammerspoon config
-- https://github.com/catskull/MusicMenuDisplay.spoon
hs.loadSpoon("MusicMenuDisplay")
-- https://github.com/catskull/CPUTempMenuDisplay.spoon
hs.loadSpoon("CPUTempMenuDisplay")
hs.window.animationDuration = 0
local workMonitor = "LG Ultra HD"
-- Super specific window layout for my 43" 4k display
local windowLayout = {
{"Slack", nil, workMonitor, nil, nil, hs.geometry.rect(-0.0,23.0,1082.0,747.0)},
{"Code", nil, workMonitor, nil, nil, hs.geometry.rect(1844.0,771.0,1936.0,1389.0)},
{"iTerm2", nil, workMonitor, nil, nil, hs.geometry.rect(2428.0,23.0,1350.0,747.0)},
{"Safari", nil, workMonitor, nil, nil, hs.geometry.rect(0,771.0,1843.0,1389.0)},
{"Google Calendar", nil, workMonitor, nil, nil, hs.geometry.rect(1083.0,23.0,1344.0,745.0)}
}
hs.layout.apply(windowLayout)
-- Apply window layout when the monitor is plugged in
local screenwatcher = hs.screen.watcher.new(function()
if (hs.screen.allScreens()[2] == nil and hs.screen.allScreens()[1]:name() == workMonitor) then
hs.layout.apply(windowLayout)
hs.alert("Welcome to work David!")
end
end)
screenwatcher:start()
-- Hotkey to apply layout if window layout gets messed up
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "space", function()
hs.layout.apply(windowLayout)
hs.alert("Default desktop applied")
end)
-- Hotkey to simulate keystrokes to get around annoying forms that disable copy paste
hs.hotkey.bind({"cmd", "alt"}, "V", function() hs.eventtap.keyStrokes(hs.pasteboard.getContents()) end)
spoon.MusicMenuDisplay:start("apple")
spoon.CPUTempMenuDisplay:start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment