From 38fe45f724d11f3bffbd74b19c83b2b7cc786a02 Mon Sep 17 00:00:00 2001 From: Marcel Kapfer Date: Thu, 20 Jul 2023 21:48:41 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20(flatpak-sync)=20Add=20remove/unins?= =?UTF-8?q?tall=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The remove/uninstall command takes a application id as a second parameter and removes it from the apps list. Afterwards the sync method is called. Refs: #1 --- flatpak-sync/flatpak-sync.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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