From 7b800e0293e0762db87f4f6f6377038c6540718b Mon Sep 17 00:00:00 2001 From: Louie S Date: Mon, 1 Jan 2024 19:51:15 -0500 Subject: Use subdirectories for installation --- .gitignore | 2 ++ rom-desktop-entry-generator.sh | 20 ++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 1df2082..14043a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ +output output/* +icon icon/* diff --git a/rom-desktop-entry-generator.sh b/rom-desktop-entry-generator.sh index dc67685..01663b4 100755 --- a/rom-desktop-entry-generator.sh +++ b/rom-desktop-entry-generator.sh @@ -8,7 +8,7 @@ STDERR_LOG=/dev/stderr BASEDIR="$(dirname "$0")" SCRIPTNAME="$(basename "$0" .sh)" DESKTOP_ENTRY_OUTPUT_DIR="$BASEDIR/output" -DESKTOP_ENTRY_INSTALL_DIR="$HOME/.local/share/applications" +DESKTOP_ENTRY_INSTALL_DIR="$HOME/.local/share/applications/$SCRIPTNAME" ICON_SOURCE_DIR="$BASEDIR/icon" ICON_INSTALL_DIR="$HOME/.local/share/icons/hicolor" @@ -18,7 +18,7 @@ build_desktop_file() { NAME="$1" ROMPATH="$2" SYSTEM="$3" - OUTPUT="$DESKTOP_ENTRY_OUTPUT_DIR/$SYSTEM/${SCRIPTNAME}_${SYSTEM}_${NAME}.desktop" + OUTPUT="$DESKTOP_ENTRY_OUTPUT_DIR/$SYSTEM/$NAME.desktop" echo "Building $NAME" >> "$STDOUT_LOG" @@ -142,13 +142,15 @@ install_wrapper() { find "$DESKTOP_ENTRY_OUTPUT_DIR/$1" -type f | while read -r file; do echo "Installing $file" >> "$STDOUT_LOG" + NAME="$(grep "^Name=" "$file" | cut -d "=" -f 2)" + SYSTEM="$(basename "$(dirname "$file")")" + # Install desktop entry # TODO look into using xdg-desktop-menu for install and uninstall - install "$file" "$DESKTOP_ENTRY_INSTALL_DIR" + mkdir -p "$DESKTOP_ENTRY_INSTALL_DIR/$SYSTEM" + install "$file" "$DESKTOP_ENTRY_INSTALL_DIR/$SYSTEM" # Install icon - NAME="$(grep "^Name=" "$file" | cut -d "=" -f 2)" - SYSTEM="$(basename "$(dirname "$file")")" install_icon "$NAME" "$SYSTEM" done @@ -185,7 +187,9 @@ uninstall_wrapper() { done # Remove the desktop entry - rm -f "$DESKTOP_ENTRY_INSTALL_DIR/$(basename "$file")" + rm -f "$DESKTOP_ENTRY_INSTALL_DIR/$(basename "$(dirname "$file")")/$(basename "$file")" + rmdir --ignore-fail-on-non-empty "$DESKTOP_ENTRY_INSTALL_DIR/$(basename "$(dirname "$file")")" + rmdir --ignore-fail-on-non-empty "$DESKTOP_ENTRY_INSTALL_DIR" done shift @@ -272,6 +276,8 @@ while [ -n "$1" ]; do install_wrapper $TARGET_SYSTEMS # Workaround to refresh icons touch "$ICON_INSTALL_DIR" + # Workaround to refresh desktop database + touch "$DESKTOP_ENTRY_INSTALL_DIR" continue ;; uninstall) @@ -280,6 +286,8 @@ while [ -n "$1" ]; do TARGET_SYSTEMS="$(ls -1 "$DESKTOP_ENTRY_OUTPUT_DIR")" fi uninstall_wrapper $TARGET_SYSTEMS + # Workaround to refresh desktop database + touch "$(dirname "$DESKTOP_ENTRY_INSTALL_DIR")" continue ;; esac -- cgit