Open albertcat opened 3 years ago
Great contribution @farwel.
Does running brew uninstall --cask $brew_cask
once most app-related files have been deleted generate errors?
Hi @sunknudsen!
No, it does not generate any errors. I can't confirm 100% but it seems it does is just remove any references that will be still in the system. Here is an example when deleting Joplin. As you can see, even after sending the app to the trash it finds the cask and shows the info of the app. Just keep in mind that if you restore the app from the trash it will not restore the cask.
$ ./app-cleaner /Applications/Joplin.app
Checking for running processes...
Finding app data...
/Applications/Joplin.app
/Users/albert/Library/Application Support/@joplin
/Users/albert/Library/Preferences/net.cozic.joplin-desktop.plist
/Users/albert/Library/Saved Application State/net.cozic.joplin-desktop.savedState
/var/folders/md/8zx6n_ws0l91l5d_s1943ynw0000gn/C/net.cozic.joplin-desktop
Move app data to trash (y or n)? y
Moving app data to trash...
Done
Cask found!
joplin: 1.7.11
https://joplin.cozic.net/
/usr/local/Caskroom/joplin/1.6.8 (120B)
From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/joplin.rb
==> Name
Joplin
==> Description
Note taking and to-do application with synchronization capabilities
==> Artifacts
Joplin.app (App)
==> Analytics
install: 650 (30 days), 2,190 (90 days), 15,422 (365 days)
Uninstall cask (y or n)? y
Uninstalling cask...
==> Uninstalling Cask joplin
==> Purging files for version 1.6.8 of Cask joplin
$
Hi! 👋 "Pending consensus" label is present, so I feel obliged to take a stand: great idea and should be implemented 😉
I think this is a good suggestion. At least on my system some apps are coming from brew as I try to avoid using App Store whenever is possible. Another suggestion for this new piece of code is to add an alert / message to remind a user that an app migh be installed from brew, and uninstalling it this way will make it impossible to restore the cask.
Hey @farwel, can you please create a pull request?
Btw, sorry for taking forever to follow up on this one.
If cask is found, should script end? In other words, looking forward to seeing where snippet is added.
Perhaps one should add a test to see if Homebrew is installed before looking for matching casks?
Hi! I've made the switch to Linux so unfortunately I can't provide a PR as I will not be able to test the code. Maybe someone can take over and update the script using the code on my first comment as a reference.
My initial suggestion was adding the snippet at the end, after moving the data to Trash check/process.
Guide
How to clean uninstall macOS apps using AppCleaner open source alternative
Operating system and version
macOS Catalina 10.15.7
Description
If you use the
app-clenaer.sh
to remove an app installed via homebrew cask, it will leave the cask references dandling in the system. I've added a check that checks for a matching "cask link", and launches the uninstall to fully clean the app from the system. Maybe somebody else can benefit from the addition. Let me know what you think.I've added it just after moving the app to Trash.