Skip to content

Commit

Permalink
Ability to relocate home directory and prevent display sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
Moonif committed May 20, 2024
1 parent 8969c6f commit 0a52b8d
Show file tree
Hide file tree
Showing 11 changed files with 674 additions and 78 deletions.
8 changes: 6 additions & 2 deletions MacBox.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
F934D58B29E41BDB00F0D450 /* AddVMViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F934D58A29E41BDB00F0D450 /* AddVMViewController.swift */; };
F934D58D29E424EE00F0D450 /* VM.swift in Sources */ = {isa = PBXBuildFile; fileRef = F934D58C29E424EE00F0D450 /* VM.swift */; };
F944ACA12B55BF230048455C /* VersionManagerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F944ACA02B55BF230048455C /* VersionManagerViewController.swift */; };
F95C5A682BF93026004BE8E9 /* ScreensaverManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = F95C5A672BF93026004BE8E9 /* ScreensaverManager.swift */; };
F95DC0462B4BD2BB006ECF05 /* GithubResponseObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = F95DC0452B4BD2BB006ECF05 /* GithubResponseObject.swift */; };
F97BF9B02B5EFF71003AB087 /* VersionInfoObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = F97BF9AF2B5EFF71003AB087 /* VersionInfoObject.swift */; };
F989DA832B754D1300F074F8 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = F989DA822B754D1300F074F8 /* Localizable.xcstrings */; };
Expand Down Expand Up @@ -39,6 +40,7 @@
F934D58A29E41BDB00F0D450 /* AddVMViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddVMViewController.swift; sourceTree = "<group>"; };
F934D58C29E424EE00F0D450 /* VM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VM.swift; sourceTree = "<group>"; };
F944ACA02B55BF230048455C /* VersionManagerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VersionManagerViewController.swift; sourceTree = "<group>"; };
F95C5A672BF93026004BE8E9 /* ScreensaverManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScreensaverManager.swift; sourceTree = "<group>"; };
F95DC0452B4BD2BB006ECF05 /* GithubResponseObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GithubResponseObject.swift; sourceTree = "<group>"; };
F97BF9AF2B5EFF71003AB087 /* VersionInfoObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VersionInfoObject.swift; sourceTree = "<group>"; };
F989DA822B754D1300F074F8 /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -81,6 +83,7 @@
F9BB907529F14C7E000B4C5F /* VMTemplate.swift */,
F9DC6A4129F874770076FC50 /* SpecsParser.swift */,
F92DF7CD2A00021800450E04 /* RunningVMProcess.swift */,
F95C5A672BF93026004BE8E9 /* ScreensaverManager.swift */,
);
path = Classes;
sourceTree = "<group>";
Expand Down Expand Up @@ -274,6 +277,7 @@
F95DC0462B4BD2BB006ECF05 /* GithubResponseObject.swift in Sources */,
F9D3370F2B6A8DD500CE75A0 /* URL.swift in Sources */,
F934D58D29E424EE00F0D450 /* VM.swift in Sources */,
F95C5A682BF93026004BE8E9 /* ScreensaverManager.swift in Sources */,
F9F47FAF2B573444008EDF4E /* JenkinsResponseObject.swift in Sources */,
F9B09E6429E9DBC800C86A0F /* IniParser.swift in Sources */,
F9F47FAD2B571DBF008EDF4E /* Date.swift in Sources */,
Expand Down Expand Up @@ -445,7 +449,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)";
MARKETING_VERSION = 0.4.7;
MARKETING_VERSION = 0.4.8;
PRODUCT_BUNDLE_IDENTIFIER = Moonif.MacBox;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -480,7 +484,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)";
MARKETING_VERSION = 0.4.7;
MARKETING_VERSION = 0.4.8;
PRODUCT_BUNDLE_IDENTIFIER = Moonif.MacBox;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
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
}
3 changes: 3 additions & 0 deletions MacBox/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {

func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
if let mainVC = MainViewController.instance {
mainVC.screensaverManager.enableScreensaver()
}
}

func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
Expand Down
32 changes: 32 additions & 0 deletions MacBox/Classes/ScreensaverManager.swift
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
}
}
}
3 changes: 2 additions & 1 deletion MacBox/Data/namedefs.inf
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ flytech386=Flytech A36
mr1217=Chaintech 325AX (MR BIOS)
pja511m=Acrosser PJ-A511M
prox1332=Protech ProX-1332
ama932j=AMA-932J
ama932j=Arche AMA-932J
adi386sx=ADI 386SX
shuttle386sx=Shuttle 386SX
cmdsl386sx16=Commodore SL386SX-16
Expand Down Expand Up @@ -436,6 +436,7 @@ aptiva510=IBM Aptiva 510/710/Vision
ma23c=NEC Mate NX MA23C
m747=PC Chips M747
pravetz16s=Pravetz 16S / CPU12
pc140_6260=IBM PC 140 (type 6260)

[cpu_family]
8088=Intel 8088
Expand Down
Loading

0 comments on commit 0a52b8d

Please sign in to comment.