Skip to content

Instantly share code, notes, and snippets.

@RafhaanShah
Last active January 13, 2022 17:48
Show Gist options
  • Save RafhaanShah/47b35ec0b291c8a5ca5824e804025696 to your computer and use it in GitHub Desktop.
Save RafhaanShah/47b35ec0b291c8a5ca5824e804025696 to your computer and use it in GitHub Desktop.
Hammerspoon Config for Wake/Sleep
function caffeinateWatcher(eventType)
if (eventType == hs.caffeinate.watcher.systemWillSleep or
eventType == hs.caffeinate.watcher.systemWillPowerOff) then
print ("Going to Sleep...")
-- Execute sleep script
-- hs.task.new("/Users/username/scripts/on_sleep.sh", nil):start()
-- hs.applescript('tell application "APP_NAME" to quit')
elseif (eventType == hs.caffeinate.watcher.systemDidWake) then
print ("Waking from Sleep...")
-- Execute wake script
-- hs.task.new("/Users/username/scripts/on_wake.sh", nil):start()
-- hs.applescript('tell application "APP_NAME" to activate')
end
end
sleepWatcher = hs.caffeinate.watcher.new(caffeinateWatcher)
sleepWatcher:start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment