EPOD Window Bar is a macOS agent app. It shows a thin strip above the Dock with one tab per window of the frontmost application. One click raises the window. Build from source with XcodeGen and Xcode. Signing uses Config.xcconfig (ad-hoc by default; a local Local.xcconfig can set a team ID). The app needs Accessibility and Screen Recording permissions, and runs in a reduced mode without Screen Recording. See README.md and docs/ for details.
68 lines
2.1 KiB
Swift
68 lines
2.1 KiB
Swift
import Foundation
|
|
import Observation
|
|
|
|
// Settings holds the user settings. The settings use UserDefaults. The keys
|
|
// have the prefix "ws." (spec section 7.13). The type is main-actor isolated
|
|
// and publishes changes with the Observation framework.
|
|
@MainActor
|
|
@Observable
|
|
final class Settings {
|
|
|
|
static let shared = Settings()
|
|
|
|
private enum Key {
|
|
static let paused = "ws.paused"
|
|
static let constrainWindows = "ws.constrainWindows"
|
|
static let excludedBundleIDs = "ws.excludedBundleIDs"
|
|
static let stripHeight = "ws.stripHeight"
|
|
}
|
|
|
|
@ObservationIgnored
|
|
private let defaults: UserDefaults
|
|
|
|
var paused: Bool {
|
|
didSet { defaults.set(paused, forKey: Key.paused) }
|
|
}
|
|
|
|
var constrainWindows: Bool {
|
|
didSet { defaults.set(constrainWindows, forKey: Key.constrainWindows) }
|
|
}
|
|
|
|
var excludedBundleIDs: [String] {
|
|
didSet { defaults.set(excludedBundleIDs, forKey: Key.excludedBundleIDs) }
|
|
}
|
|
|
|
var stripHeight: Double {
|
|
didSet { defaults.set(stripHeight, forKey: Key.stripHeight) }
|
|
}
|
|
|
|
init(defaults: UserDefaults = .standard) {
|
|
self.defaults = defaults
|
|
defaults.register(defaults: [
|
|
Key.paused: false,
|
|
Key.constrainWindows: true,
|
|
Key.excludedBundleIDs: [String](),
|
|
Key.stripHeight: 30.0
|
|
])
|
|
paused = defaults.bool(forKey: Key.paused)
|
|
constrainWindows = defaults.bool(forKey: Key.constrainWindows)
|
|
excludedBundleIDs = defaults.stringArray(forKey: Key.excludedBundleIDs) ?? []
|
|
stripHeight = defaults.double(forKey: Key.stripHeight)
|
|
}
|
|
|
|
// isExcluded returns true if the application is on the excluded list.
|
|
func isExcluded(_ bundleID: String?) -> Bool {
|
|
guard let bundleID = bundleID else { return false }
|
|
return excludedBundleIDs.contains(bundleID)
|
|
}
|
|
|
|
func addExcluded(_ bundleID: String) {
|
|
guard excludedBundleIDs.contains(bundleID) == false else { return }
|
|
excludedBundleIDs.append(bundleID)
|
|
}
|
|
|
|
func removeExcluded(_ bundleID: String) {
|
|
excludedBundleIDs.removeAll { $0 == bundleID }
|
|
}
|
|
}
|