From d0677d0f05c6f17a022fd1cf868ebbf0b83877db Mon Sep 17 00:00:00 2001 From: Fierelier Date: Wed, 29 Nov 2023 04:56:03 +0100 Subject: [PATCH] Add cmd: app-unexport --- README.txt | 3 +++ app/cmd/app-unexport | 24 ++++++++++++++++++++++++ app/cmd/help | 5 ++++- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100755 app/cmd/app-unexport diff --git a/README.txt b/README.txt index b24cbfd..5882c45 100644 --- a/README.txt +++ b/README.txt @@ -22,3 +22,6 @@ Start a program within a prefix. If PROOTH_ROOT is set to 1, it will use setting * app-export Add a desktop launcher from the prefix to the host. + +* app-unexport +Remove a desktop launcher of a prefix from the host. diff --git a/app/cmd/app-unexport b/app/cmd/app-unexport new file mode 100755 index 0000000..2f0e7c6 --- /dev/null +++ b/app/cmd/app-unexport @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +set -e +FULL_PREFIX="$(realpath -s "$1")" +HASH_PREFIX=($(echo "$FULL_PREFIX" | md5sum)) +DESKTOP_FILE="$2" + +if ! [ -f "$DESKTOP_FILE" ]; then + if [ -f "$HOME/.local/share/applications/$HASH_PREFIX-$2.desktop" ]; then + DESKTOP_FILE="$HOME/.local/share/applications/$HASH_PREFIX-$2.desktop" + fi +fi + +while IFS="" read -r p || [ -n "$p" ] +do + shopt -s nullglob + if [[ "$p" == "Icon="* ]]; then + ICON="${p/Icon=/}" + for ICON_FILE in "$HOME/.icons/hicolor/"*"/"*"/$ICON."*; do + rm -f "$ICON_FILE" + done + fi + shopt -u nullglob +done < "$DESKTOP_FILE" +rm -f "$DESKTOP_FILE" diff --git a/app/cmd/help b/app/cmd/help index 93f9160..9b48820 100755 --- a/app/cmd/help +++ b/app/cmd/help @@ -8,5 +8,8 @@ Show this help. Start a program within a prefix. If PROOTH_ROOT is set to 1, it will use settings that emulate root rights. * app-export -Add a desktop launcher from the prefix to the host.\ +Add a desktop launcher from the prefix to the host. + +* app-unexport +Remove a desktop launcher of a prefix from the host.\ "