This is kind of a shortcoming of all package management in general; should deleting the package delete your user data? There’s an argument to be made that data should be removed with the application, but deleting data irrecoverably as the default isn’t necessarily the easiest approach.
There’s also another problem, which is that the behaviour of deleting data may make sense for per-user applications, but for system-wide apps, should uninstalling an application start nuking data in people’s homedirs?
For fun, a shell script for the same functionality:
<span style="color:#323232;">#!/bin/sh
</span><span style="color:#323232;">br="$(printf "n")" # Obtain a line-break
</span><span style="color:#323232;">
</span><span style="color:#323232;"># If RM_CMD is unset, use trash-cli
</span><span style="color:#323232;">if [ -z ${RM_CMD+y} ]; then RM_CMD="trash"; fi
</span><span style="color:#323232;">
</span><span style="color:#323232;"># List of apps. The leading br is necessary for later pattern matching
</span><span style="color:#323232;">apps="$br$(flatpak list --columns=application)" || exit 1
</span><span style="color:#323232;">
</span><span style="color:#323232;">cd ~/.var/app || exit 1
</span><span style="color:#323232;">
</span><span style="color:#323232;">for app in *; do
</span><span style="color:#323232;"> case "$apps" in
</span><span style="color:#323232;"> *"$br$app$br"*) ;; # Matches if $app is in the list (installed)
</span><span style="color:#323232;"> *)
</span><span style="color:#323232;"> printf 'Removing app data %sn' "${app}"
</span><span style="color:#323232;"> "$RM_CMD" "./${app}"
</span><span style="color:#323232;"> ;;
</span><span style="color:#323232;"> esac
</span><span style="color:#323232;">done
</span>
<span style="color:#323232;">#!/bin/bash
</span><span style="color:#323232;">
</span><span style="color:#323232;"># List contents of ~/.var/app/
</span><span style="color:#323232;">files=$(ls -1 ~/.var/app/)
</span><span style="color:#323232;">
</span><span style="color:#323232;"># Loop through each element of the folder
</span><span style="color:#323232;">for file in $files; do
</span><span style="color:#323232;"> # Set the name as a variable
</span><span style="color:#323232;"> app_name="${file##*/}"
</span><span style="color:#323232;">
</span><span style="color:#323232;"> # Check if a flatpak app of that name is installed
</span><span style="color:#323232;"> if ! flatpak list 2> /dev/null | grep -qw $app_name; then
</span><span style="color:#323232;"> # Ask the user to delete the folder
</span><span style="color:#323232;"> read -p "The app $app_name is not installed. Do you want to delete its folder? (y/n): " choice
</span><span style="color:#323232;"> case "$choice" in
</span><span style="color:#323232;"> [Yy]* )
</span><span style="color:#323232;"> # Remove the folder recursively
</span><span style="color:#323232;"> rm -rf ~/.var/app/$file;;
</span><span style="color:#323232;"> [Nn]* )
</span><span style="color:#323232;"> echo "Skipping deletion of $app_name folder.";;
</span><span style="color:#323232;"> * )
</span><span style="color:#323232;"> echo "Invalid input. Skipping deletion of $app_name folder.";;
</span><span style="color:#323232;"> esac
</span><span style="color:#323232;"> fi
</span><span style="color:#323232;">done
</span><span style="color:#323232;">
</span><span style="color:#323232;">echo "All Apps checked."
</span>
Because there are distros, like fedora for one, that have flat packs installable by the likes of discovery on KDE that doesn’t require CLI useage for install or uninstall of flatpacks
As far as I can tell this seems to be for deleting application data (~/.var/app/*), whereas flatpak uninstall --unused is for uninstalling runtimes that are no longer needed.
Add comment