Please use the tool with caution, as it’s still under development. In my testing, it worked properly, but I might have missed something. Please report any bug found while testing.
While exams, I got bored, so, I created a tool, that allows to cleanup the datas of uninstalled snaps, remove old revisions of snaps via simple GUI prompts. Check this out.
To install the script, run
System Wide Installation
sudo make install
Per user installation
make install
Please ignore the README for now. I wrote it using AI, as I didn’t have much time back then, but I do now.
#!/bin/bash
clean_revision() {
LC_ALL=C snap list --all | tail -n+2 | awk '/[, ]disabled/ {print $1, $3}' | while read -r line; do
(
set -e
echo "$line" | (
read -r name revision
test -n "$name"
test -n "$revision"
sudo snap remove "$name" --revision "$revision"
)
)
done
}
clean_unused() {
LC_ALL=C snap list | tail -n+2 | awk '{print $1}' | while read -r snap_name; do
(
set -e
case "$snap_name" in
snapd|core*)
# TODO deal with unused base snaps
exit 0
;;
esac
conns="$(snap connections "$snap_name" | tail -n+2)"
# for content snap which is unused, conenctions is a single line
# an look like this:
# content - gnome-3-28-1804:gnome-3-28-1804 -
if [ "$(echo "$conns" | wc -l)" != "1" ]; then
# snap has other slots/plugs
exit 0
fi
if echo "$conns" | grep -Eq "content +- +$snap_name:.*"; then
sudo snap remove "$snap_name"
fi
)
done
}
case "$1" in
--unused)
clean_unused
;;
*)
clean_revision
;;
esac