Skip to content

Instantly share code, notes, and snippets.

@latenitefilms
Created August 30, 2022 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save latenitefilms/c2874084b1babebd895d477a8bd786b0 to your computer and use it in GitHub Desktop.
Save latenitefilms/c2874084b1babebd895d477a8bd786b0 to your computer and use it in GitHub Desktop.
Restart Loupedeck Software on Wake from Sleep
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