Created
August 30, 2022 02:03
-
-
Save latenitefilms/c2874084b1babebd895d477a8bd786b0 to your computer and use it in GitHub Desktop.
Restart Loupedeck Software on Wake from Sleep
This file contains hidden or 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
local loupedeckServiceBundleID = "com.loupedeck.Loupedeck2" | |
local loupdeckConfigBundleID = "com.loupedeck.loupedeckconfig" | |
shouldRestart = false | |
local function sleepWatcherCallback(event) | |
if event == hs.caffeinate.watcher.systemWillSleep then | |
-- If going to sleep, lets kill the Loupedeck Service: | |
local app = hs.application.get(loupedeckServiceBundleID) | |
if app then | |
app:kill9() | |
shouldRestart = true | |
print("Killing the Loupedeck Service") | |
end | |
-- Do the same for the LoupedeckConfig application: | |
app = hs.application.get(loupedeckServiceBundleID) | |
if app then | |
app:kill9() | |
shouldRestart = true | |
print("Killing the LoupedeckConfig application") | |
end | |
elseif event == hs.caffeinate.watcher.systemDidWake then | |
if shouldRestart then | |
hs.application.launchOrFocusByBundleID(loupedeckServiceBundleID) | |
print("Restarting the Loupedeck Service") | |
end | |
shouldRestart = false | |
end | |
end | |
sleepWatcher = hs.caffeinate.watcher.new(sleepWatcherCallback):start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment