forked from Moonif/MacBox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ability to relocate home directory and prevent display sleep
- Loading branch information
Showing
11 changed files
with
674 additions
and
78 deletions.
There are no files selected for viewing
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
7 changes: 4 additions & 3 deletions
7
MacBox.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
{ | ||
"originHash" : "b26c070fd1f0b029780331f3cefa3909a6d58ea6b3ae242bffe49d6011fe06fe", | ||
"pins" : [ | ||
{ | ||
"identity" : "zipfoundation", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/weichsel/ZIPFoundation.git", | ||
"state" : { | ||
"revision" : "b979e8b52c7ae7f3f39fa0182e738e9e7257eb78", | ||
"version" : "0.9.18" | ||
"revision" : "02b6abe5f6eef7e3cbd5f247c5cc24e246efcfe0", | ||
"version" : "0.9.19" | ||
} | ||
} | ||
], | ||
"version" : 2 | ||
"version" : 3 | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// ScreensaverManager.swift | ||
// MacBox | ||
// | ||
// Created by Moonif on 5/18/24. | ||
// | ||
|
||
import IOKit.pwr_mgt | ||
|
||
class ScreensaverManager { | ||
private var assertionID: IOPMAssertionID = 0 | ||
private let assertionName = "Moonif.MacBox.preventsleep" as CFString | ||
var sleepDisabled = false | ||
|
||
// Disable screensaver & screen sleep | ||
func disableScreensaver() { | ||
if !sleepDisabled { | ||
sleepDisabled = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep as CFString, | ||
IOPMAssertionLevel(kIOPMAssertionLevelOn), | ||
assertionName, | ||
&assertionID) == kIOReturnSuccess | ||
} | ||
} | ||
|
||
// Enable screensaver & screen sleep (release the assertion) | ||
func enableScreensaver() { | ||
if sleepDisabled { | ||
IOPMAssertionRelease(assertionID) | ||
sleepDisabled = false | ||
} | ||
} | ||
} |
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
Oops, something went wrong.