Last active
January 13, 2022 17:48
-
-
Save RafhaanShah/47b35ec0b291c8a5ca5824e804025696 to your computer and use it in GitHub Desktop.
Hammerspoon Config for Wake/Sleep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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