From 124ba7b071ac8a289a233dadb04d15fbfc2dffbd Mon Sep 17 00:00:00 2001 From: Santiago Lo Coco Date: Sun, 14 Apr 2024 14:33:10 +0200 Subject: [PATCH] Fix bugs and refactor --- clauncher | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/clauncher b/clauncher index 29f2950..25f4464 100755 --- a/clauncher +++ b/clauncher @@ -4,14 +4,17 @@ cacheDir=${XDG_CACHE_HOME:-"$HOME/.cache"} configDir=${XDG_CONFIG_HOME:-"$HOME/.config"}/clauncher cacheFile="$cacheDir/launcher_opts" historyFile="$cacheDir/launcher_opts_history" +ignoreFile="$configDir/.open_ignore" +addFile="$configDir/.open_add" +locationsFile="$configDir/.open_locations" update_cache() { if ! [[ -f "$cacheFile" ]] || [[ "$1" == "force" ]]; then - if [ -f "$customLocationsFile" ]; then + if [ -f "$locationsFile" ]; then while IFS= read -r location; do locations+=("$location") - done < "$customLocationsFile" + done < "$locationsFile" else locations=( "$HOME/Applications" @@ -20,7 +23,7 @@ update_cache() { ) fi - find . "${locations[@]}" -maxdepth 2 -name "*.app" -type d | gxargs -d '\n' basename | sed 's/\.app$//' | ({ [ -f "$configDir/.open_ignore" ] && grep -v -f "$configDir/.open_ignore"; } || cat -) | ([ -f "$configDir/.open_add" ] && cat "$configDir/.open_add"; cat -) | sort -u > "$cacheFile" + find . "${locations[@]}" -maxdepth 2 -name "*.app" -type d | gxargs -d '\n' basename | sed 's/\.app$//' | ({ [ -f "$ignoreFile" ] && grep -v -f "$ignoreFile"; } || cat -) | ([ -f "$addFile" ] && cat "$addFile"; cat -) | sort -u > "$cacheFile" fi }