A simple utility that cleans the Spotify cache based on a user-defined threshold. Simple, right?
Spotify is notorious for creating a cache that can grow significantly over time. Sure, you can manually clear it via Spotify's app settings by pressing Clear Cache
, but let’s face it — I’m lazy. To address this, I created a simple Lua utility that automatically clears the cache when it exceeds 150 MB.
But why exactly do I care about clearing Spotify’s cache? One day, I noticed Spotify consuming an absurd amount of CPU and memory. After investigating, I discovered that the app had accumulated over 3 GB of cache. Once I cleared it and restarted Spotify, the app stopped hogging system resources.
So here we are—a straightforward, automated solution for lazy people like me!
P.S.: I know Spotify allows you to set a cache limit, but where’s the fun in that when you can over-engineer a solution? 😉
This project requires the following utilities:
-
Lua: The programming language used for this project. You can download and install Lua from its official website.
-
Luastatic: A command-line tool that compiles a Lua program into a standalone executable. Learn more and install it from GitHub or via luarocks.
-
Make: A build automation tool. If it’s not already installed, you can install it on most Linux (debian-based) systems with:
sudo apt install make
.
Tip
By running the configure
binary, all these dependencies will be checked, and, if needed, they will be installed for you. Even the default directory of the storage and data files of Spotify.
To install, and therefore use this utility, first download the most recent release. Then simply run the following commands:
./configure
This command will check every dependency that you may need in your system, and it will install everything for you. After that, just run:
sudo make install
After the installation is completed you should have the spotify-cleaner
usable system-wide and a new cronjob
(that checks the cache size every five hours) created! After that, you can safely remove the project release downloaded.
If you wish to modify the utility (e.g., path, cache size, etc.), you can edit the file located at src/main.lua
and then proceed again with the installation steps.
If you desire to uninstall the utility, you can simply run:
sudo make uninstall
This command will remove both the spotify-cleaner
utility installed system-wide and the cronjob
created during the installation process.
If you have any questions regarding the utility, its usage, or encounter any errors you're struggling with, please feel free to open an issue in this repository, or contact me via email at [email protected].
Contributions to this utility are welcome! If you encounter any issues, have suggestions for improvements, or would like to add new features, please submit a pull request. I appreciate your feedback and contributions to make this utility even better.
This project is under the GPL 3.0 license.