conver
2022-11-18 11:43:57 +08:00
```
-- brew install hammerspoon
-- brew install smudge/smudge/nightlight
function nightlightControl(state)
cmd = "/usr/local/bin/nightlight " .. (state)
ok, result = hs.osascript.applescript(string.format('do shell script "%s"', cmd))
return result
end
function caffeinateCallback(eventType)
if (eventType == hs.caffeinate.watcher.screensDidUnlock) then
if (string.match(nightlightControl('status'), 'on')) then
nightlightControl('off')
nightlightControl('on')
end
end
end
caffeinateWatcher = hs.caffeinate.watcher.new(caffeinateCallback)
caffeinateWatcher:start()
```