Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Uninstalling finds an app's startup item in /Library/StartupItems

Țugui Dragoș97932ebfae7f
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 70a6386d..f235c3bf 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -112514,6 +112514,112 @@
}
}
},
+ "Startup Item" : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Položka při spuštění"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Startobjekt"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ítem de arranque"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ouverture au démarrage"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Elemento di avvio"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "起動項目"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "시동 항목"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Opstartonderdeel"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Rzecz startowa"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Item de Inicialização"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Articol de inițializare"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Объект запуска"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Startobjekt"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Başlangıç Öğesi"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Елемент автозапуску"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "启动项"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "啟動項目"
+ }
+ }
+ }
+ },
"State" : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swift
index 10995d13..288d3d07 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swift
@@ -20,6 +20,8 @@ public struct SearchLocation: Sendable, Hashable {
case launchAgents
case launchDaemons
case privilegedHelperTools
+ /// `/Library/StartupItems`, where older software keeps a folder that runs at startup.
+ case startupItems
/// The folders macOS loads plug-ins from.
case plugIns
/// The two files that are an installer receipt, which is how macOS still counts a package as installed.
@@ -69,6 +71,7 @@ extension SearchLocation.Kind {
case .launchAgents: self = .launchAgents
case .launchDaemons: self = .launchDaemons
case .privilegedHelperTools: self = .privilegedHelperTools
+ case .startupItems: self = .startupItems
case .audioUnits, .audioDrivers, .vst, .vst3, .clap, .midiDrivers, .internetPlugIns, .preferencePanes, .quickLook,
.screenSavers, .spotlight, .services, .inputMethods, .colorPickers, .contextualMenuItems, .mailBundles,
.aax, .mas, .imageUnits, .dictionaries, .automatorActions, .contactsPlugIns:
diff --git a/Packages/PeelCore/Sources/PeelCore/Plugins/Plugins.swift b/Packages/PeelCore/Sources/PeelCore/Plugins/Plugins.swift
index 676455e9..9916adf0 100644
--- a/Packages/PeelCore/Sources/PeelCore/Plugins/Plugins.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Plugins/Plugins.swift
@@ -70,7 +70,7 @@ extension Plugin.Category {
case .contactsPlugIns: self = .contactsPlugIns
case .applicationSupport, .applicationScripts, .caches, .containers, .groupContainers, .preferences,
.preferencesByHost, .savedApplicationState, .recentDocuments, .logs, .httpStorages, .webKit, .cookies,
- .launchAgents, .launchDaemons, .privilegedHelperTools:
+ .launchAgents, .launchDaemons, .privilegedHelperTools, .startupItems:
return nil
}
}
diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/AppReset.swift b/Packages/PeelCore/Sources/PeelCore/Removal/AppReset.swift
index ac27c61d..ba64ba41 100644
--- a/Packages/PeelCore/Sources/PeelCore/Removal/AppReset.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Removal/AppReset.swift
@@ -90,8 +90,8 @@ public struct AppReset: Sendable {
.appData
// A reset leaves these alone. What every account on the Mac shares is not one user's to reset, and a
// plug-in is code that macOS loads, not a setting.
- case .launchAgents, .launchDaemons, .privilegedHelperTools, .plugIns, .receipts, .library, .sharedFolder,
- .hiddenHomeFiles, .homeFolder, .commandLineTools, .elsewhere:
+ case .launchAgents, .launchDaemons, .privilegedHelperTools, .startupItems, .plugIns, .receipts, .library,
+ .sharedFolder, .hiddenHomeFiles, .homeFolder, .commandLineTools, .elsewhere:
nil
}
}
diff --git a/Packages/PeelCore/Sources/PeelPrivileged/LibraryFolder.swift b/Packages/PeelCore/Sources/PeelPrivileged/LibraryFolder.swift
index 0151c0e7..219e95cd 100644
--- a/Packages/PeelCore/Sources/PeelPrivileged/LibraryFolder.swift
+++ b/Packages/PeelCore/Sources/PeelPrivileged/LibraryFolder.swift
@@ -17,6 +17,9 @@ public enum LibraryFolder: String, CaseIterable, Sendable {
case launchAgents = "LaunchAgents"
case launchDaemons = "LaunchDaemons"
case privilegedHelperTools = "PrivilegedHelperTools"
+ /// Apple's "Creating a Startup Item", Daemons and Services Programming Guide: the folder older software installs
+ /// its startup items in.
+ case startupItems = "StartupItems"
case audioUnits = "Audio/Plug-Ins/Components"
case audioDrivers = "Audio/Plug-Ins/HAL"
case vst = "Audio/Plug-Ins/VST"
@@ -63,6 +66,7 @@ public enum LibraryFolder: String, CaseIterable, Sendable {
/// The folders searched in the Mac's own `/Library`, besides the plug-in folders.
public static let local: [LibraryFolder] = [
.applicationSupport, .caches, .preferences, .logs, .launchAgents, .launchDaemons, .privilegedHelperTools,
+ .startupItems,
]
public static let inTheUsersLibrary = user + plugIns
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
index 6a38c307..3d1ec60e 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
@@ -965,6 +965,30 @@ struct LeftoverScannerTests {
#expect(scan.leftovers.count == 1, "the kext was reached twice or its folder was offered")
}
+ /// A startup item an app's package installed in `/Library/StartupItems` is found by its folder's name and moved
+ /// through the helper, which serves that folder; the folder itself is never offered.
+ @Test(.permissionsHold) func findsTheAppsStartupItem() async throws {
+ let directory = try TemporaryDirectory()
+ let app = InstalledApp(
+ url: URL(filePath: "/Applications/Hexachord.app"),
+ bundleIdentifier: "org.example.hexachord",
+ name: "Hexachord"
+ )
+ try directory.file("root/Library/StartupItems/Hexachord/Hexachord", bytes: 64)
+ try directory.file("root/Library/StartupItems/Hexachord/StartupParameters.plist", bytes: 64)
+ try directory.setPermissions(0o555, of: "root/Library/StartupItems")
+ defer { try? directory.setPermissions(0o755, of: "root/Library/StartupItems") }
+
+ let found = await LeftoverScanner(environment: environment(in: directory)).scan(app, installedApps: [app])
+ let scan = found.holdingBack(beyond: HelperReach(environment: environment(in: directory)), leaving: app.url)
+
+ let item = try #require(scan.leftovers.first { $0.url.lastPathComponent == "Hexachord" })
+ #expect(item.kind == .startupItems)
+ #expect(item.requiresPrivileges)
+ #expect(item.match.heldBack != .beyondTheHelper)
+ #expect(scan.leftovers.count == 1)
+ }
+
/// A file system an app's package installed stays in `/Library/Filesystems` after the app goes, and is listed the
/// same way: found by the identifier it declares, never selected, since the helper does not serve that folder.
@Test(.permissionsHold) func listsTheAppsFileSystemWithoutEverSelectingIt() async throws {
diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swift
index 2f0a267d..f5525294 100644
--- a/Peel/Views/Presentation.swift
+++ b/Peel/Views/Presentation.swift
@@ -65,6 +65,7 @@ extension SearchLocation.Kind {
case .launchAgents: "Launch Agent"
case .launchDaemons: "Launch Daemon"
case .privilegedHelperTools: "Helper Tool"
+ case .startupItems: "Startup Item"
case .plugIns: "Plug-in"
case .receipts: "Installer Receipt"
case .library: "Library Folder"
@@ -93,6 +94,7 @@ extension SearchLocation.Kind {
case .httpStorages, .webKit, .cookies: "globe"
case .launchAgents, .launchDaemons: "gearshape.2"
case .privilegedHelperTools: "lock.shield"
+ case .startupItems: "power"
case .plugIns: "powerplug"
case .receipts: "doc.text.below.ecg"
case .library: "building.columns"