Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Read a tweak's layers in the order macOS searches them
Țugui Dragoș9fdce164307f
diff --git a/AGENTS.md b/AGENTS.mdindex ff5be8e1..2390ee4f 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -296,10 +296,11 @@ If you are unsure whether something belongs in the helper, it doesn't.- **Apple's lookup is limited and lags a release.** Apple limits `itunes.apple.com/lookup` to about 20 calls aminute, so a process asks no faster (`RequestWindow`), and a copy of its catalog can name an older version forhours after a release, so an answer older than an update already found counts as a check that failed.-- **A setting has layers, and Peel writes one of them.** macOS reads a key from a profile first, then from this- Mac's own layer, the person's, every account's, and, for an app's domain, the global domain's, and the first that- holds it wins. Peel writes the person's layer for every Mac, so a value it can't change from there shows with a- lock: one set for this Mac alone, and a switch that is on only through a layer below the person's (`TweakStore`).+- **A setting has layers, and Peel writes one of them.** macOS reads a key from a profile first, then from the+ person's layer for this Mac and for every Mac, then, for an app's domain, the person's global domain, and then every+ account's layers, and the first that holds it wins. Peel writes the person's layer for every Mac, so a value it+ can't change from there shows with a lock: one set for this Mac alone, and a switch that is on only through a layer+ below the person's (`TweakStore`).`defaults write` with no type stores a number as text, so a number is read from its text too, as`UserDefaults.double(forKey:)` reads it.diff --git a/Packages/PeelCore/Sources/PeelCore/Tweaks/TweakStore.swift b/Packages/PeelCore/Sources/PeelCore/Tweaks/TweakStore.swiftindex 63ab28b4..42de26cb 100644--- a/Packages/PeelCore/Sources/PeelCore/Tweaks/TweakStore.swift+++ b/Packages/PeelCore/Sources/PeelCore/Tweaks/TweakStore.swift@@ -62,16 +62,19 @@ public struct TweakStore: Sendable, TweakStoring {return TweakState(isOn: isOn, isManaged: isManaged, text: text, heldElsewhere: elsewhere)}- /// What each layer macOS searches holds for a key, in the order it searches them. The layer Peel writes is- /// the person's own for any host; a value set for this Mac alone comes before it, and the layers of every- /// account and, for a key of an app's domain, of the global domain come after it.+ /// What each layer macOS searches holds for a key. The layer Peel writes is the person's own for any host; a value+ /// set for this Mac alone comes before it, and after it, for a key of an app's domain, the person's global domain,+ /// then every account's layers of the app and of the global domain ("Preference Domains", Apple's Preferences+ /// Programming Topics for Core Foundation).struct Layers {var thisMac: CFPropertyList?var own: CFPropertyList?var everyAccount: CFPropertyList?+ /// The person's own global domain.var everyApp: CFPropertyList?+ var everyAccountForEveryApp: CFPropertyList?- var inEffect: CFPropertyList? { thisMac ?? own ?? everyAccount ?? everyApp }+ var inEffect: CFPropertyList? { thisMac ?? own ?? everyApp ?? everyAccount ?? everyAccountForEveryApp }}private func layers(of tweak: Tweak) -> Layers {@@ -93,7 +96,7 @@ public struct TweakStore: Sendable, TweakStoring {let global = kCFPreferencesAnyApplicationlayers.everyApp = value(kCFPreferencesCurrentUser, kCFPreferencesCurrentHost, in: global)?? value(kCFPreferencesCurrentUser, kCFPreferencesAnyHost, in: global)- ?? value(kCFPreferencesAnyUser, kCFPreferencesCurrentHost, in: global)+ layers.everyAccountForEveryApp = value(kCFPreferencesAnyUser, kCFPreferencesCurrentHost, in: global)?? value(kCFPreferencesAnyUser, kCFPreferencesAnyHost, in: global)}return layers@@ -106,8 +109,9 @@ public struct TweakStore: Sendable, TweakStoring {static func heldElsewhere(of kind: Tweak.Kind, isOn: Bool, in layers: Layers) -> TweakState.Elsewhere? {if layers.thisMac != nil { return .thisMac }guard layers.own == nil, case .aSwitch = kind, isOn else { return nil }+ if layers.everyApp != nil { return .everyApp }if layers.everyAccount != nil { return .everyAccount }- return layers.everyApp != nil ? .everyApp : nil+ return layers.everyAccountForEveryApp != nil ? .everyApp : nil}/// Returns what the key holds in the layer Peel writes (this user, any host), so it can be put back exactlydiff --git a/Packages/PeelCore/Tests/PeelCoreTests/TweakTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/TweakTests.swiftindex d7581f5c..bcdb0035 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/TweakTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/TweakTests.swift@@ -151,6 +151,15 @@ struct TweakTests {#expect(TweakStore.heldElsewhere(of: forThisApp, isOn: true, in: layers(thisMac: true)) == .thisMac)}+ @Test func readsThePersonsGlobalValueBeforeEveryAccountsAsMacOSDoes() {+ let layers = TweakStore.Layers(+ thisMac: nil, own: nil, everyAccount: false as CFBoolean, everyApp: true as CFBoolean+ )++ #expect(layers.inEffect as? Bool == true)+ #expect(TweakStore.heldElsewhere(of: .aSwitch(.boolean(true)), isOn: true, in: layers) == .everyApp)+ }+@Test func callsTheGlobalDomainWhatTheApiCallsIt() {#expect(TweakStore.domain("NSGlobalDomain") == kCFPreferencesAnyApplication)#expect(TweakStore.domain("com.apple.dock") == "com.apple.dock" as CFString)