-
Notifications
You must be signed in to change notification settings - Fork 27
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
Showing
7 changed files
with
96 additions
and
20 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,60 @@ | ||
// | ||
// CurrentlyDisabledDaemonView.swift | ||
// Geranium | ||
// | ||
// Created by cclerc on 21.12.23. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct CurrentlyDisabledDaemonView: View { | ||
let plistPath = "/var/mobile/Documents/disabled.plist" | ||
@Environment(\.dismiss) var dismiss | ||
@State private var data: [String: Bool] = [:] | ||
|
||
var body: some View { | ||
NavigationView { | ||
List { | ||
Section(header: Text("Disabled Daemons Manager"), footer: Text("This is a list of all the currently disabled daemons. Don't change things you didn't changed. The toggled ones are the disabled ones.")) { | ||
ForEach(data.sorted(by: { $0.key < $1.key }), id: \.key) { key, value in | ||
Toggle(isOn: Binding( | ||
get: { data[key] ?? false }, | ||
set: { data[key] = $0 } | ||
)) { | ||
Text(key) | ||
} | ||
} | ||
} | ||
} | ||
.navigationBarTitle("Manage") | ||
.navigationBarItems(trailing: | ||
Button("Save") { | ||
saveIt() | ||
close() | ||
} | ||
) | ||
} | ||
.onAppear { | ||
loadIt() | ||
} | ||
} | ||
private func loadIt() { | ||
if let dict = NSDictionary(contentsOfFile: plistPath) as? [String: Bool] { | ||
data = dict | ||
} | ||
} | ||
private func saveIt() { | ||
(data as NSDictionary).write(toFile: plistPath, atomically: true) | ||
var result = RootHelper.removeItem(at: URL(fileURLWithPath: "/var/db/com.apple.xpc.launchd/disabled.plist")) | ||
print(result) | ||
result = RootHelper.move(from: URL(fileURLWithPath :"/var/mobile/Documents/disabled.plist"), to: URL(fileURLWithPath: "/var/db/com.apple.xpc.launchd/disabled.plist")) | ||
print(result) | ||
} | ||
func close() { | ||
dismiss() | ||
} | ||
} | ||
|
||
#Preview { | ||
CurrentlyDisabledDaemonView() | ||
} |
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
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