diff --git a/flatpak-sync/flatpak-sync.sh b/flatpak-sync/flatpak-sync.sh index 2601f4f..0db2e90 100755 --- a/flatpak-sync/flatpak-sync.sh +++ b/flatpak-sync/flatpak-sync.sh @@ -56,6 +56,26 @@ function add() { echo "$appId" >> "$appsListFile" } +function remove() { + local appId="${2:-}" + + if [[ -z "$appId" ]]; then + echo "No application ID given." + exit 1 + fi + + if ! grep "$appId" "$APPS_LIST_PATH"; then + echo "App not in apps list." + exit 2 + fi + + local appsListFile + appsListFile="$(realpath "$APPS_LIST_PATH")" + appsListTmpFile="$(mktemp)" + grep -v "$appId" "$APPS_LIST_PATH" >> "$appsListTmpFile" + mv "$appsListTmpFile" "$appsListFile" +} + cmd="${1:-}" case "$cmd" in @@ -63,6 +83,10 @@ case "$cmd" in add "$@" sync ;; + r|remove|u|uninstall ) + remove "$@" + sync + ;; * ) sync esac