You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to make a small script for pre-sleep tasks. I've tried hs.task.waitUntilExit() after hs.task.new("/Users/USER/do_before_sleep", nil):start() but macOS (14.2.1) enters sleep prior tasks are finished.
Is it possible to accomplish with Hammerspoon?
Here is my code:
function caffeinateWatcher(eventType)
if (eventType == hs.caffeinate.watcher.systemWillSleep) then
print ("WillSleep...")
-- Execute sleep script
hs.task.new("/Users/YOURNAME/.sleep", nil):start()
elseif (eventType == hs.caffeinate.watcher.systemDidWake) then
print ("Woken...")
-- Execute wake script
hs.task.new("/Users/YOURNAME/.wakeup", nil):start()
end
end
sleepWatcher = hs.caffeinate.watcher.new(caffeinateWatcher)
sleepWatcher:start()
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello!
Trying to make a small script for pre-sleep tasks. I've tried
hs.task.waitUntilExit()
afterhs.task.new("/Users/USER/do_before_sleep", nil):start()
but macOS (14.2.1) enters sleep prior tasks are finished.Is it possible to accomplish with Hammerspoon?
Here is my code:
Beta Was this translation helpful? Give feedback.
All reactions