diff --git a/Sources/SketchyBarToggleCore/PrerequisiteChecker.swift b/Sources/SketchyBarToggleCore/PrerequisiteChecker.swift index 9708c07..26cf8d3 100644 --- a/Sources/SketchyBarToggleCore/PrerequisiteChecker.swift +++ b/Sources/SketchyBarToggleCore/PrerequisiteChecker.swift @@ -25,17 +25,7 @@ public struct PrerequisiteReport { } public final class PrerequisiteChecker { - private let sketchybarPath: String - - public init() { - if FileManager.default.fileExists(atPath: "/opt/homebrew/bin/sketchybar") { - sketchybarPath = "/opt/homebrew/bin/sketchybar" - } else if FileManager.default.fileExists(atPath: "/usr/local/bin/sketchybar") { - sketchybarPath = "/usr/local/bin/sketchybar" - } else { - sketchybarPath = "sketchybar" - } - } + public init() {} public func check() -> PrerequisiteReport { var issues: [String] = [] @@ -95,8 +85,8 @@ public final class PrerequisiteChecker { private func querySketchyBar() -> (running: Bool, topmost: String?) { let process = Process() - process.executableURL = URL(fileURLWithPath: sketchybarPath) - process.arguments = ["--query", "bar"] + process.executableURL = URL(fileURLWithPath: "/usr/bin/env") + process.arguments = ["sketchybar", "--query", "bar"] let pipe = Pipe() process.standardOutput = pipe diff --git a/Sources/SketchyBarToggleCore/SketchyBarController.swift b/Sources/SketchyBarToggleCore/SketchyBarController.swift index bfb2487..5b0eab5 100644 --- a/Sources/SketchyBarToggleCore/SketchyBarController.swift +++ b/Sources/SketchyBarToggleCore/SketchyBarController.swift @@ -2,17 +2,7 @@ import Foundation /// Controls SketchyBar visibility by shelling out to the `sketchybar` CLI. public final class SketchyBarController: BarController { - private let sketchybarPath: String - - public init() { - if FileManager.default.fileExists(atPath: "/opt/homebrew/bin/sketchybar") { - sketchybarPath = "/opt/homebrew/bin/sketchybar" - } else if FileManager.default.fileExists(atPath: "/usr/local/bin/sketchybar") { - sketchybarPath = "/usr/local/bin/sketchybar" - } else { - sketchybarPath = "sketchybar" - } - } + public init() {} public func hide() { // Instant hide — macOS menu bar is already sliding in @@ -27,8 +17,8 @@ public final class SketchyBarController: BarController { private func run(arguments: [String]) { let process = Process() - process.executableURL = URL(fileURLWithPath: sketchybarPath) - process.arguments = arguments + process.executableURL = URL(fileURLWithPath: "/usr/bin/env") + process.arguments = ["sketchybar"] + arguments process.standardOutput = FileHandle.nullDevice process.standardError = FileHandle.nullDevice @@ -42,8 +32,8 @@ public final class SketchyBarController: BarController { private func runAsync(arguments: [String]) { let process = Process() - process.executableURL = URL(fileURLWithPath: sketchybarPath) - process.arguments = arguments + process.executableURL = URL(fileURLWithPath: "/usr/bin/env") + process.arguments = ["sketchybar"] + arguments process.standardOutput = FileHandle.nullDevice process.standardError = FileHandle.nullDevice