hammerspoon/modules/system.lua
2020-10-09 17:36:23 +08:00

18 lines
501 B
Lua

local hotkey = require "hs.hotkey"
local caffeinate = require "hs.caffeinate"
local audiodevice = require "hs.audiodevice"
hotkey.bind(hyper, "L", function()
caffeinate.lockScreen()
-- caffeinate.startScreensaver()
end)
-- mute on sleep
function muteOnWake(eventType)
if (eventType == caffeinate.watcher.systemDidWake) then
local output = audiodevice.defaultOutputDevice()
output:setMuted(true)
end
end
caffeinateWatcher = caffeinate.watcher.new(muteOnWake)
caffeinateWatcher:start()