Skip to content

Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit

Homebrew compatibility work, lets homebrew run Remove Everything when NotProton is removed with brew uninstall --zap

NotProtonNot5c18baa95aa8
diff --git a/app/Sources/NotProtonApp/App.swift b/app/Sources/NotProtonApp/App.swift
index 8b3bd59..e431792 100644
--- a/app/Sources/NotProtonApp/App.swift
+++ b/app/Sources/NotProtonApp/App.swift
@@ -2,7 +2,6 @@
import SwiftUI
-@main
struct NotProtonApp: App {
@State private var status = SystemStatus()
diff --git a/app/Sources/NotProtonApp/Support/Launch.swift b/app/Sources/NotProtonApp/Support/Launch.swift
new file mode 100644
index 0000000..945ec62
--- /dev/null
+++ b/app/Sources/NotProtonApp/Support/Launch.swift
@@ -0,0 +1,11 @@
+import Foundation
+
+@main
+enum Launch {
+ static func main() {
+ if CommandLine.arguments.dropFirst().contains(RemoveEverythingCommand.flag) {
+ RemoveEverythingCommand.run()
+ }
+ NotProtonApp.main()
+ }
+}
diff --git a/app/Sources/NotProtonApp/Support/RemoveEverythingCommand.swift b/app/Sources/NotProtonApp/Support/RemoveEverythingCommand.swift
new file mode 100644
index 0000000..3dfad3d
--- /dev/null
+++ b/app/Sources/NotProtonApp/Support/RemoveEverythingCommand.swift
@@ -0,0 +1,45 @@
+import Foundation
+
+enum RemoveEverythingCommand {
+ static let flag = "--remove-everything"
+
+ static func run() -> Never {
+ Task.detached { exit(await perform()) }
+ dispatchMain()
+ }
+
+ private static func perform() async -> Int32 {
+ do {
+ let lock = try DeploymentContent.acquireInstallationLock(for: SupportPaths.Steam.app)
+ defer { close(lock) }
+ let output = Output()
+ let result = try await Uninstall.run { phase in
+ if case .restoring(.finished) = phase { return }
+ output.say(phase.label)
+ }
+ output.say(
+ result.restoredValveSignature
+ ? "NotProton has been removed."
+ : "NotProton has been removed. Steam needs to be redownloaded. "
+ + "Please run Repair Steam again once you are online."
+ )
+ return 0
+ } catch {
+ FileHandle.standardError.write(Data("\(error.localizedDescription)\n".utf8))
+ return 1
+ }
+ }
+
+ private final class Output: @unchecked Sendable {
+ private let lock = NSLock()
+ private var last: String?
+
+ func say(_ line: String) {
+ lock.withLock {
+ guard line != last else { return }
+ last = line
+ FileHandle.standardOutput.write(Data("\(line)\n".utf8))
+ }
+ }
+ }
+}