I dont normally like these kinds of utilities… so I figured I would make one.
Its up on gitlab:
Example run:
Its still early days.
Every action prompts the user first, with default response being negative.
I am still compiling all of the ‘cleaning actions’ it should take.
It should loop through any number of AUR helpers installed.
(includes: pacaur, pamac, paru, pikaur, trizen, yay)
SNAP/Flatpak cleanings are also included to the best of my knowledge, but I dont use either.
(and these will only be presented if snap is running or flatpak is installed)
As always feedback is welcome.
Let me know if its doing something dumb or if there is something you think should be included.
I’m just wondering why the thumbnail cache is cleaned separately using the mtime when immediately afterwards the home cache (which contains the thumbnail directories) is cleaned using the atime. Wouldn’t it be better to use atime on the thumbnails as well? If using mtime, thumbnails which are accessed on a regular (such as daily) basis will still be deleted every 2 weeks, requiring the writing of new, identical thumbnails to the disk.
Also, it might be wise to omit the Firefox cache folder from cleaning as Firefox manages its own cache. This is what I’ve been using for quite a few years in my own cleanup script which runs every startup:
@Takakage
Thats what I get for doing a last minute check, but not checking what I did during said check.
@scotty65
I agree I should probably use access for both.
The reasoning for keeping them separate was to … well, keep it separate … so that one wishing to only delete the thumbnails (which on its own can grow rather large over time) without necessarily wanting to purge the whole cache of anything ‘old’.
I think I might adopt your attitude towards the firefox cache … possibly adding others to the omission (chromium, thunderbird).
I see where you’re coming from. Maybe just changing the menu option to “Clean thumbnail cache of ALL files older than 2 weeks (y/N)?” would prevent any confusion.
Overall, the script is a very good idea. It has always irritated me ever since I started using GNU/Linux in 2005 that there is no automated function to clean old, unused files from the cache.
I changed and added some things, due in part to the comments here. @scotty65@Takakage
Of note: Incorporated fixes from above, new prompt for orphans, and a check/warning of pacnews.
EDIT.
Update again. Now with -h (help) and -a (automatic ‘yes’ mode) options.
Original mode of ‘just run and get prompted’ still intact.
And a note on the name…
Yes its Manjaro+clean but as usual it has multiple interpretations…
Its also one letter away from a certain common cleaning product, and phonetically similar to certain regal figure of yesteryear.
Cheers until next time.
EDIT AGAIN.
More updates.
Put in a check to disallow running as root, pacnew warning now only fires if you have them, and added a snazzy icon.
ToDo: Find a new extra-permissive (joke?) license.
./maclean
Clean thumbnail cache of files not accessed for 2 weeks (y/N)?
y
Clean HOME cache of files not accessed for 2 weeks (y/N)?
y
Clean journal of all logs older than 2 weeks (y/N)?
y
Vacuuming done, freed 0B of archived journals from /var/log/journal.
Vacuuming done, freed 0B of archived journals from /run/log/journal.
Vacuuming done, freed 0B of archived journals from /var/log/journal/d24beb85f3334ebb96b273459eede537.
Clean old and unused Flatpak REFs (y/N)?
y
Nothing unused to uninstall
Fehler: Error opening directory '/home/weingeist/.var/app': Datei oder Verzeichnis nicht gefunden
If you do not use flatpak and answer yes, the script will be cancelled.
Thanks. That comes from flatpak uninstall --delete-data.
This prompt only shows up if you have flatpak installed … but since flatpak fails out trying to clean if it cant find that folder … I will make this part only fire if the directory exists.
(the whole prompt only fires if flatpak is installed … but that doesnt mean you have been using it)
…And done.
EDIT.
More updates.
Now with support for npm and pip caches.
EDIT AGAIN.
Updates again.
Better prompt for automatic mode (gives warning, resets sudo, asks for password verify)
Even less prompting now (package cache checked before asking, ex: no prompt for uninstalled cache if there are none)
Also added some more output like “Done” and “Skipped”.
And one more thing most will not notice
(for the paranoid … its a check for ancient flash directories)
The heaviest functions still do not check prior to prompting.
I consider the load too high to do automatically (these all rely on traversing the filesystem to some degree). But this does all add up to a rather slim output if the system is clean;
$ ./maclean
Clean thumbnail cache of files not accessed for 2 weeks (y/N)? y
Done
Clean HOME cache of files not accessed for 2 weeks (y/N)? y
Done
Clean AUR Helper cache of all build files (y/N)? n
Skipped
All major browser caches are skipped (vivaldi, brave, chromium, chrome, ff, thunderbird)
Many internals to make it a bit faster and such.
The big one is a now -easily- configurable “junk directories” that the user can augment, at the top of the script. It replaces the previous check for ancient flash folders, which now become the default population of the junk folders.
PS. Settled on beerware license for now. Not my most favorite, but one I had not used yet.
( I have of course double checked and it runs here. )
EDIT.
While I havent heard back from @wes33 yet…
I did make some changes to the script.
Please try the latest version and let me know how it works for you.
I like to actually keep them super permissive.
Otherwise I would make sure to rant all my personal politics etc.
Though … I have been tempted by the “Be Gay Do Crimes” License, and this one: https://github.com/ErikMcClure/bad-licenses/blob/master/Bantown-public-license
(which stipulates you must commit no less than 3 US criminal offenses )
Violating the terms of the license should count for at least one …
I jest about using them of course though.
As I said - I like them to be permissive so that people can be/feel free with it.
(But that certainly doesnt mean I cant have fun with it … I still think I like the cat supremacy license best … the final line is something like “all others are given the above rights, albeit grudgingly”)
As shown in the table below, the cache directories for pkgfile and PackageKit are now checked.**
The gitlab page has a fancy table now
(That looks like this)
Operation
Clean
Remove
Paths
Notes
User-defined Junk
~/.adobe , ~/.macromedia
Default targets listed. Edit or add to the array in the script.
Thumbnail cache
~/.cache/thumbnails
Keep anything accessed within last 2 weeks.
$HOME cache
~/.cache
Keep select directories*. Keep anything accessed within last 2 weeks.
Journal logs
Keep anything accessed within last 2 weeks.
SNAP data
~/.snap , ~/snap
Cleaning if installed. Removal if uninstalled.
Flatpak data
~/.var/app
Cleaning if installed. Removal if uninstalled.
npm cache
~/.npm
Cleaning if installed. Removal if uninstalled.
pip cache
~/.cache/pip
Cleaning if installed. Removal if uninstalled.
pkgfile cache
/var/cache/pkgfile
Removal if uninstalled.
PackageKit cache
/var/cache/PackageKit
Cleaning if installed. Removal if uninstalled.
AUR Helper cache
Loop through supported AUR Helpers to invoke their cleaning flags.
Package cache
Remove all uninstalled cache and/or remove all but 2 latest installed cache.
Orphan Packages
Remove all orphan packages. Please review before confirmation.
pacnew+pacsave files
Warning Only. Use pacdiff to manage.
** I have neither installed, but they left behind directories in /var/cache, so I expect it may be similar for others. Using either software with Arch/Manjaro is not recommended.