From 5c3b7e0c00ed08acf79c445e13fbbc869be6f355 Mon Sep 17 00:00:00 2001 From: techguy16 <88870951+techguy16@users.noreply.github.com> Date: Wed, 6 May 2026 19:41:25 +1200 Subject: [PATCH 1/3] Cache application categories to speed up browsing --- api | 45 ++++++++++++++++++++++ gui | 113 ++++++++++++++----------------------------------------- settings | 3 ++ update | 5 +++ 4 files changed, 81 insertions(+), 85 deletions(-) diff --git a/api b/api index 6f1dd8e..ff3a9e1 100755 --- a/api +++ b/api @@ -166,6 +166,51 @@ search_apps() { fi } +cache_categories() { + # $1 - apps dir + # $2 - include Pi-Apps? + yad --title="LinStore" \ + --class="LinStore" \ + --center --borders=10 \ + --text "Generating app cache..." \ + --no-buttons & + + if [ -e "${1}/app_categories" ]; then + rm -f "${1}/app_categories" + fi + + for app_dir in "${1}"/*; do + app_name=$(basename "${app_dir}") + if [ -e "${1}/$app_name/category" ]; then + echo "$app_name|$(cat "${1}/$app_name/category")" >> "${1}/app_categories" + fi + done + + if [[ "$2" == "TRUE" ]]; then + if [ -e "$HOME/pi-apps/etc/categories" ]; then + while IFS= read -r line; do + app_name=$(echo "$line" | awk -F'|' '{print $1}') + category=$(grep -r "$(echo "$line" | awk -F'|' '{print $2}')" etc/mapping | head -n1 | awk -F'|' '{print $2}') + echo "$app_name|$category" >> "${1}/app_categories" + done < "$HOME/pi-apps/etc/categories" + fi + fi + + sort "${1}/app_categories" > "${1}/app_categories.tmp" + mv "${1}/app_categories.tmp" "${1}/app_categories" + + pkill -f "yad*" +} + +get_categories() { + cat etc/categories +} + +get_apps_in_category() { + local category="$1" + grep "|$category$" etc/categories | cut -d'|' -f1 +} + update() { pkill -f "yad*" ./api info "Updating LinStore..." diff --git a/gui b/gui index 87bc285..dcf65c3 100755 --- a/gui +++ b/gui @@ -1,5 +1,7 @@ #!/bin/bash +source api + APP_STORE_NAME="LinStore" APP_STORE_WIDTH=320 APP_STORE_HEIGHT=600 @@ -74,71 +76,6 @@ list_piapps() { fi } -read_categories() { - while read -r category; do - categories["$category"]="" - done "${1}/$app_name/category" - category_file="${1}/$app_name/category" - else - continue - fi - else - continue - fi - fi - - category_file="${1}/$app_name/category" - install_script="$app_dir/install" - - # Check if the install script or architecture-specific install scripts exist for this app - if [ -e "$install_script" ]; then - while IFS= read -r app_in_category; do - # Make sure $app_in_category is not empty before accessing the array - if [ -n "$app_in_category" ]; then - if [ -n "${categories[$app_in_category]}" ]; then - categories["$app_in_category"]+=" $app_name" - category_apps["$app_in_category"]+="|$app_name" - else - categories["$app_in_category"]="$app_name" - category_apps["$app_in_category"]="$app_name" - fi - fi - break - done <"$category_file" - else - architecture=$(cat ~/.linstore/architecture.txt) - install_script_arch="install-$architecture" - - if [ -e "$app_dir/$install_script_arch" ]; then - while IFS= read -r app_in_category; do - # Make sure $app_in_category is not empty before accessing the array - if [ -n "$app_in_category" ]; then - if [ -n "${categories[$app_in_category]}" ]; then - categories["$app_in_category"]+=" $app_name" - category_apps["$app_in_category"]+="|$app_name" - else - categories["$app_in_category"]="$app_name" - category_apps["$app_in_category"]="$app_name" - fi - fi - break - done <"$category_file" - fi - fi - done -} - get_app_description() { app_name="$1" description_file="apps/$app_name/description" @@ -284,9 +221,12 @@ show_apps_in_category() { formatted_apps=() if [ "$1" == "All Apps" ]; then title="All Apps" - for app_dir in apps/*; do - app_name=$(basename "$app_dir") - if [ -e "$app_dir/install" ] || [ -e "$app_dir/install-$(cat ~/.linstore/architecture.txt)" ]; then + while IFS= read -r line; do + app_name=$(echo "$line" | awk -F'|' '{print $1}') + app_dir="apps/$app_name" + if [ -e "$app_dir/install" ] || [ -e "$app_dir/install-$(cat ~/.linstore/architecture.txt)" ] \ + || [ -e "$HOME/pi-apps/apps/$app_name/install-$(cat ~/.linstore/architecture.txt)" ] \ + || [ -e "$HOME/pi-apps/apps/$app_name/install" ]; then app_icon="apps/$app_name/icon-24.png" formatted_apps+=("$app_icon") if [ -e "$HOME/.linstore/installscripts/$app_name" ]; then @@ -295,22 +235,26 @@ show_apps_in_category() { formatted_apps+=("$app_name") fi fi - done + done < "apps/app_categories" else - apps_in_category="${category_apps["$1"]}" title="Apps in $1 Category" #formatted_apps=() - IFS='|' read -r -a app_list <<<"$apps_in_category" - for app in "${app_list[@]}"; do - app_icon="apps/$app/icon-24.png" - formatted_apps+=("$app_icon") - if [ -e "$HOME/.linstore/installscripts/$app" ]; then - formatted_apps+=("$app") - else - formatted_apps+=("$app") + while IFS= read -r line; do + [[ $(echo "$line" | awk -F'|' '{print $2}') == "$1" ]] || continue + app=$(echo "$line" | awk -F'|' '{print $1}') + if [ -e "apps/$app/install" ] || [ -e "apps/$app/install-$(cat ~/.linstore/architecture.txt)" ] \ + || [ -e "$HOME/pi-apps/apps/$app/install-$(cat ~/.linstore/architecture.txt)" ] \ + || [ -e "$HOME/pi-apps/apps/$app/install" ]; then + app_icon="apps/$app/icon-24.png" + formatted_apps+=("$app_icon") + if [ -e "$HOME/.linstore/installscripts/$app" ]; then + formatted_apps+=("$app") + else + formatted_apps+=("$app") + fi fi - done + done < "apps/app_categories" fi GTK_THEME="${theme}" GDK_BACKEND=x11 $YAD_COMMAND --text "$title" --geometry=${APP_STORE_WIDTH}x${APP_STORE_HEIGHT}+${categoryPos}+${categoryPosY} --center --columns="2" \ @@ -330,13 +274,8 @@ show_apps_in_category() { } show_app_store() { - read_categories "apps" - if [[ "$use_piapps" == "TRUE" ]]; then - read_categories "/home/${USER}/pi-apps/apps" - fi - # Sort categories alphabetically and format with newlines - sorted_categories=$(printf '%s\n' "${!categories[@]}" | sort) + sorted_categories=$(printf '%s\n' "$(get_categories)" | sort) list_items=() list_items=("images/categories/All Apps.png" "All Apps") @@ -373,6 +312,10 @@ show_app_store() { fi } +if [ ! -e apps/app_categories ]; then + cache_categories "apps" "$(list_piapps)" +fi + if [[ $1 == "" ]]; then ./api logo ./api buildinfo diff --git a/settings b/settings index f6552b9..02c04f5 100755 --- a/settings +++ b/settings @@ -1,5 +1,7 @@ #!/bin/bash +source api + APP_STORE_DIRECTORY="apps" CATEGORIES_FILE="etc/categories" THEMES_DIRECTORY="/usr/share/themes" @@ -139,6 +141,7 @@ show_settings() { import_from_piapps=$(echo "$fixed_settings" | awk -F '|' '{print $5}') echo $import_from_piapps > "etc/pi-apps-import" + cache_categories "apps" "$(cat "etc/pi-apps-import" 2> /dev/null || echo FALSE)" express_updates=$(echo "$fixed_settings" | awk -F '|' '{print $6}') echo $express_updates > "etc/express-updates" diff --git a/update b/update index a823a90..3c9f191 100755 --- a/update +++ b/update @@ -1,5 +1,7 @@ #!/bin/bash +source api + if [[ $(xrandr --current) =~ "connected primary" ]]; then resolution=$(xrandr --current | grep " connected primary" | awk '{print $4}' | cut -d'+' -f1) else @@ -33,6 +35,9 @@ check_for_updates() { mv ~/.linstore/tmp/apps ./apps sleep 1 + echo '# Update app cache' + cache_categories "apps" "$(cat "etc/pi-apps-import" 2> /dev/null || echo FALSE)" + # Clean up # rm -rf ~/.linstore/tmp echo "# Finished" From 294f61334bcfb1fa4fa638e950fc5d627c419d07 Mon Sep 17 00:00:00 2001 From: techguy16 <88870951+techguy16@users.noreply.github.com> Date: Thu, 7 May 2026 18:00:07 +1200 Subject: [PATCH 2/3] Improve support for listing apps from Pi-Apps --- api | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- gui | 35 +++---------------------- 2 files changed, 86 insertions(+), 34 deletions(-) diff --git a/api b/api index ff3a9e1..d3f9ac5 100755 --- a/api +++ b/api @@ -31,7 +31,7 @@ logo() { # Function to install an app install_app() { - local app_directory="$1" + local app_directory="$(get_app_directory "$2")" local selected_app_name="$2" local installed_file="$HOME/.linstore/installed" local temp_script=$(mktemp) @@ -73,7 +73,7 @@ open_app() { # Function to install an app installation_script() { - local app_directory="$1" + local app_directory="$(get_app_directory "$2")" local selected_app_name="$2" local installed_file="$HOME/.linstore/installed" @@ -97,7 +97,7 @@ installation_script() { # Function to uninstall an app uninstall_app() { - local app_directory="$1" + local app_directory="$(get_app_directory "$2")" local selected_app_name="$2" local uninstalled_file="$HOME/.linstore/uninstalled" local temp_script=$(mktemp) @@ -211,6 +211,79 @@ get_apps_in_category() { grep "|$category$" etc/categories | cut -d'|' -f1 } +get_app_description() { + app_name="$1" + description_file="apps/$app_name/description" + if [ -e "$description_file" ]; then + cat "$description_file" + elif [ -e "$HOME/pi-apps/apps/$app_name/description" ]; then + cat "$HOME/pi-apps/apps/$app_name/description" + else + echo "No description available." + fi +} +get_app_creator() { + app_name="$1" + creator_file="apps/$app_name/creator" + if [ -e "$creator_file" ]; then + cat "$creator_file" + elif [ -e "$HOME/pi-apps/apps/$app_name/credits" ]; then + cat "$HOME/pi-apps/apps/$app_name/credits" + else + echo "No description available." + fi +} +get_app_website() { + app_name="$1" + website_file="apps/$app_name/website" + if [ -e "$website_file" ]; then + cat "$website_file" + else + echo "No description available." + fi +} +get_app_directory() { + app_name="$1" + if [ -d "apps/$app_name" ]; then + echo "apps/$app_name" + elif [ -d "$HOME/pi-apps/apps/$app_name" ]; then + echo "$HOME/pi-apps/apps/$app_name" + else + echo "" + fi +} + +install_packages() { + packages="$@" + sudo apt update > /dev/null 2>&1 + + for package in $packages; do + if [[ "$package" == http* ]]; then + echo "Downloading and installing $package..." + wget --no-check-certificate "$package" -O /tmp/package.deb > /dev/null 2>&1 + sudo dpkg -i /tmp/package.deb > /dev/null 2>&1 + rm -r /tmp/package.deb + elif [[ "$package" == *.deb ]]; then + echo "Installing $package using dpkg..." + sudo dpkg -i "$package" > /dev/null 2>&1 + else + echo "Installing $package using apt..." + + sudo apt install "$package" -y > /dev/null 2>&1 + fi + done +} + +git_clone() { + if [ -z "$2" ]; then + local directory=$(basename "$1") + else + local directory="$2" + fi + + git clone "$1" "$directory" +} + update() { pkill -f "yad*" ./api info "Updating LinStore..." @@ -237,6 +310,12 @@ information() { printf '\033[1;104;30m INFO:\033[0;104m %s \033[0m\n' "$msg" >&2 } +export -f install_packages +export -f error +export -f warning +export -f information +export -f git_clone + # Main logic to handle command line arguments if [[ $1 == "search" ]]; then search_apps diff --git a/gui b/gui index dcf65c3..7c27dcf 100755 --- a/gui +++ b/gui @@ -76,33 +76,6 @@ list_piapps() { fi } -get_app_description() { - app_name="$1" - description_file="apps/$app_name/description" - if [ -e "$description_file" ]; then - cat "$description_file" - else - echo "No description available." - fi -} -get_app_creator() { - app_name="$1" - creator_file="apps/$app_name/creator" - if [ -e "$creator_file" ]; then - cat "$creator_file" - else - echo "No description available." - fi -} -get_app_website() { - app_name="$1" - website_file="apps/$app_name/website" - if [ -e "$website_file" ]; then - cat "$website_file" - else - echo "No description available." - fi -} theme_get() { website_file="etc/theme" if [ -e "$website_file" ]; then @@ -159,8 +132,8 @@ app_details_page() { local selected_app_name="${1//|/}" selected_app_name=$(echo "$selected_app_name" | sed 's/<[^>]*>//g') - local app_directory="apps/$selected_app_name" - local app_icon="$app_directory/icon-48.png" + local app_directory="$(get_app_directory "$selected_app_name")" + local app_icon="$app_directory/icon-64.png" local description=$(get_app_description "$selected_app_name") local creator=$(get_app_creator "$selected_app_name") local website=$(get_app_website "$selected_app_name") @@ -227,7 +200,7 @@ show_apps_in_category() { if [ -e "$app_dir/install" ] || [ -e "$app_dir/install-$(cat ~/.linstore/architecture.txt)" ] \ || [ -e "$HOME/pi-apps/apps/$app_name/install-$(cat ~/.linstore/architecture.txt)" ] \ || [ -e "$HOME/pi-apps/apps/$app_name/install" ]; then - app_icon="apps/$app_name/icon-24.png" + app_icon="$(get_app_directory "$app_name")/icon-24.png" formatted_apps+=("$app_icon") if [ -e "$HOME/.linstore/installscripts/$app_name" ]; then formatted_apps+=("$app_name") @@ -246,7 +219,7 @@ show_apps_in_category() { if [ -e "apps/$app/install" ] || [ -e "apps/$app/install-$(cat ~/.linstore/architecture.txt)" ] \ || [ -e "$HOME/pi-apps/apps/$app/install-$(cat ~/.linstore/architecture.txt)" ] \ || [ -e "$HOME/pi-apps/apps/$app/install" ]; then - app_icon="apps/$app/icon-24.png" + app_icon="$(get_app_directory "$app")/icon-24.png" formatted_apps+=("$app_icon") if [ -e "$HOME/.linstore/installscripts/$app" ]; then formatted_apps+=("$app") From cc268edeaed90c6125b5893f6e8d91c6a3622f6e Mon Sep 17 00:00:00 2001 From: techguy16 <88870951+techguy16@users.noreply.github.com> Date: Fri, 8 May 2026 08:28:31 +1200 Subject: [PATCH 3/3] Update gitignore to not include configuration files --- .gitignore | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index cbd3f99..1472561 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,7 @@ -/updates_list.txt \ No newline at end of file +/updates_list.txt +/apps/app_categories +/etc/accent +/etc/editor +/etc/express-updates +/etc/pi-apps-import +/etc/theme \ No newline at end of file