SplashBuddy
SplashBuddy copied to clipboard
Keep the machine from sleeping.
I am hoping there is an option to keep the machine from going to sleep while splash buddy is active.
hmmm... I would think adding a line in the code like caffeinate -d -i -m -u & then upon completion kill it ?
We could probably use this https://developer.apple.com/library/content/releasenotes/Darwin/RN-IOKitPowerManagment/
But I would be surprised it would work in a sandboxed app!
this is (I believe) the current way: https://developer.apple.com/library/content/qa/qa1340/_index.html
I ended up using:
caffeinate -d -i -m -u &
then killing the process, this has worked well for me.
Thanks for all the comments :)
You could also let caffeinate
execute the process:
$ caffeinate -dimsu /path/to/executable
will maintain the assertions until the executable
ends. Should save a few lines of code.
Hi All I am struggling with the Sleep/ScreenSaver. During my deployments it activates the screensaver. And Locks my screen. I want to fix this with the Caffeinate (or any other way). But can somebody help me to add Caffeinate to the SplashBuddy.lunch.sh script? I tryed it. But it did not work for me. Would be great to suspend the screensaver with this Caffeinate tool. Thanks for your help.
#!/bin/bash
# This file should be called by a LaunchAgent
# Its goal is to ensure SplashBuddy only executes when user is on the desktop.
# I suggest you create a Policy to Remove and uninstall the LaunchAgent
# We cannot do it here as LaunchAgent are executed by the user.
loggedInUser=$(/usr/bin/python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");')
app="/Library/Application Support/SplashBuddy/SplashBuddy.app"
doneFile="/Users/${loggedInUser}/Library/Containers/io.fti.SplashBuddy/Data/Library/.SplashBuddyDone"
# Check if:
# - SplashBuddy is not already running
# - SplashBuddy is signed (is fully installed)
# - User is in control (not _mbsetupuser)
# - User is on desktop (Finder process exists)
# - Done file doesn't exist
function appInstalled {
/usr/bin/codesign --verify "${app}" && return 0 || return 1
}
function appNotRunning {
/usr/bin/pgrep SplashBuddy && return 1 || return 0
}
function finderRunning {
/usr/bin/pgrep Finder && return 0 || return 1
}
if appNotRunning \
&& appInstalled \
&& [ "$loggedInUser" != "_mbsetupuser" ] \
&& finderRunning \
&& [ ! -f "${doneFile}" ]; then
/usr/bin/open -a "$app"
fi
exit 0
( We should probably implement it in code https://developer.apple.com/library/archive/qa/qa1340/_index.html )
( We should probably implement it in code https://developer.apple.com/library/archive/qa/qa1340/_index.html )
Would be great to add this code in new version 👍
Got some working on while testing
requires both import IOKit
and import IOKit.pwr_mgt
You call the function like this: self.disableScreenSleep(reason: "Installing required applications."
Will work on implementing this into SplashBuddy.
var assertionID: IOPMAssertionID = 0
var success: IOReturn?
func disableScreenSleep(reason: String = "Unknown reason") -> Bool? {
//guard success != nil else { return nil }
success = IOPMAssertionCreateWithName( kIOPMAssertionTypeNoDisplaySleep as CFString,
IOPMAssertionLevel(kIOPMAssertionLevelOn),
reason as CFString,
&assertionID )
return success == kIOReturnSuccess
}
func enableScreenSleep() -> Bool {
if success != nil {
success = IOPMAssertionRelease(0)
success = nil
return true
}
return false
}
Changing /usr/bin/open -a "$app"
to /usr/bin/caffeinate -dimsu "/Library/Application Support/SplashBuddy/SplashBuddy.app/Contents/MacOS/SplashBuddy"
worked for me