xscreensaver: add uninstall_postflight and zap

* Add uninstall_postflight to remove installed screensavers

* Add zap
This commit is contained in:
Justin Krehel
2023-11-04 19:17:03 -04:00
parent 2ea72eaa6c
commit f7c0f3efe3
+21
View File
@@ -14,9 +14,30 @@ cask "xscreensaver" do
pkg "Install Everything.pkg"
# There is no uninstall script for this Cask, so a manual uninstall is performed
# Loop through all screensaver plist files, looking for "org,jwz" in the bundle identifier
# Then remove the screensaver if the bundle identifier matches
uninstall_postflight do
Pathname.glob("/Library/Screen Savers/*.saver/Contents/Info.plist").each do |plist|
bundle_id = `/usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' "#{plist}"`
next unless bundle_id.start_with?("org.jwz")
screensaver_name = `/usr/libexec/PlistBuddy -c 'Print :CFBundleExecutable' "#{plist}"`.delete(" ").strip
screensaver = Pathname.new("/Library/Screen Savers/#{screensaver_name}.saver")
Utils.gain_permissions_remove(screensaver) if screensaver.directory?
end
end
uninstall pkgutil: "org.jwz.xscreensaver",
delete: [
"/Applications/Apple2.app",
"/Applications/Phosphor.app",
"/Library/Screen Savers/XScreenSaverUpdater.app",
]
zap trash: [
"~/Library/HTTPStorages/org.jwz.xscreensaver.XScreenSaverUpdater",
"~/Library/Preferences/org.jwz.xscreensaver.*.plist",
"~/Library/Saved Application State/org.jwz.xscreensaver.*.savedState",
]
end