-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
30148ee
commit 8bbf489
Showing
5 changed files
with
72 additions
and
2 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
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,36 @@ | ||
import Foundation | ||
import Combine | ||
import AppKit | ||
|
||
protocol JustUpdatedCheckerProtocol: ObservableObject { | ||
var justUpdated: Bool { get } | ||
} | ||
|
||
class JustUpdatedChecker: ObservableObject, JustUpdatedCheckerProtocol { | ||
|
||
@Published var justUpdated: Bool = false | ||
|
||
init() { | ||
check() | ||
} | ||
|
||
func check() { | ||
let lastBuild = UserDefaults.standard.object(forKey: Constants.previousVersionUserDefaultsKey) as? String ?? "None" | ||
let currentBuild = Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String | ||
UserDefaults.standard.set(currentBuild, forKey: Constants.previousVersionUserDefaultsKey) | ||
if lastBuild != currentBuild { | ||
justUpdated = true | ||
} | ||
} | ||
|
||
|
||
|
||
} | ||
|
||
extension JustUpdatedChecker { | ||
|
||
enum Constants { | ||
static let previousVersionUserDefaultsKey = "com.maxgoedjen.Secretive.lastBuild" | ||
} | ||
|
||
} |
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,19 @@ | ||
import Foundation | ||
import ServiceManagement | ||
|
||
struct LaunchAgentController { | ||
|
||
func install() -> Bool { | ||
setEnabled(true) | ||
} | ||
|
||
func relaunch() { | ||
_ = setEnabled(false) | ||
_ = setEnabled(true) | ||
} | ||
|
||
private func setEnabled(_ enabled: Bool) -> Bool { | ||
SMLoginItemSetEnabled("com.maxgoedjen.Secretive.SecretAgent" as CFString, enabled) | ||
} | ||
|
||
} |
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