diff --git a/.gitignore b/.gitignore index cbd3f99..dbdbb26 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,10 @@ -/updates_list.txt \ No newline at end of file +/updates_list.txt +/architecture.txt +/installed +/apps/app_categories +/etc/accent +/etc/editor +/etc/express-updates +/etc/pi-apps-import +/etc/theme +/installscripts* \ No newline at end of file diff --git a/README.md b/README.md index 996823f..021eb00 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,6 @@ Submit a new app

-## ⚠️ SCAM ALERT -Recently, I have been made aware of a repository which is claiming to offer an "updated version" of LinStore but instead provides a download for malicious software. - -If you come across one of these repositories using LinStore's branding to ship malware, please report it. Thanks! - ## Welcome to LinStore! LinStore is the Linux desktop's best app store, but it's also the lightest and fastest graphical store available, using less RAM than another popular lightweight app store.^ @@ -40,6 +35,21 @@ To install LinStore, run the following command: curl -s -L https://raw.githubusercontent.com/techguy16/LinStore/main/install | bash ``` +
+Install LinStore using Pi-Apps + +1. Open Pi-Apps +2. Click the Settings icon +3. Click "Import App" +4. Paste the following URL in the box: +``` +https://raw.githubusercontent.com/techguy16/LinStore/refs/heads/main/etc/tools/LinStore.zip +``` +5. Click "OK" +6. Click "Save". LinStore should now be listed in the applications list. Click on it, then click "Install". + +
+
Manually install LinStore @@ -51,6 +61,15 @@ chmod +x install ```
+
+Uninstall LinStore + +```bash +rm -irf ~/.linstore/!(installscripts) +rm -f $HOME/.local/share/applications/LinStore.desktop $HOME/Desktop/LinStore.desktop +``` +
+
### Launching LinStore @@ -66,14 +85,14 @@ To launch LinStore via the command line, run the following command:
-### Supported operating systems - **Debian** 13/12/11 +### Supported distributions + **Debian** 13/12/11 - **Ubuntu** 24.04/22.04/20.04 LTS + **Ubuntu** 26.04/24.04/22.04/20.04 LTS - **Linux Mint** 22.x/21.x/20.x + **Linux Mint** 22.x/21.x/20.x - **Pop!_OS** 22.04/20.04 + **Pop!_OS** 24.04/22.04/20.04 **Raspberry Pi OS** - versions based on supported **Debian** versions are supported (images from after **8th Nov 2021**) @@ -82,8 +101,6 @@ To launch LinStore via the command line, run the following command: ### Installing Pi-Apps apps LinStore has the ability to install non-package apps from Pi-Apps.

To do so, import a ZIP file for a Pi-Apps app or enable the "Show apps from Pi-Apps (if installed)" option in LinStore's settings, which will show Pi-Apps' app library if it is installed. -

-install_package and remove_package are separate scripts, unlike Pi-Apps which uses a large script (manage) for everything. ### LinStore badges @@ -97,4 +114,13 @@ If you have an app listed on LinStore, consider adding a badge to your README to [](https://github.com/techguy16/LinStore) ```markdown [](https://github.com/techguy16/LinStore) -``` \ No newline at end of file +``` + + +## Contributing + +LinStore welcomes contributions, however small or big they are: + +* [Submit](https://github.com/techguy16/LinStore/issues/new?template=app-submission.yml) or [suggest](https://github.com/techguy16/LinStore/issues/new?template=app-request.yml) apps to be added to the app library +* [Reporting bugs](https://github.com/techguy16/LinStore/issues/new?template=bug.yml) with LinStore +* Or even just starring the repository! \ No newline at end of file diff --git a/api b/api index 6f1dd8e..34e33b5 100755 --- a/api +++ b/api @@ -9,8 +9,22 @@ fi horizontal=$(echo $resolution | cut -d'x' -f1) vertical=$(echo $resolution | cut -d'x' -f2) +linstore_directory() { + if [ -e "$HOME/.linstore/directory" ]; then + cat "$HOME/.linstore/directory" + elif [ -e "$(pwd)/gui" ]; then + echo "$(pwd)" + else + echo "$HOME/.linstore" + fi +} + +api_script() { + echo "$(linstore_directory)/api" +} + theme_get() { - website_file="etc/theme" + website_file="$(linstore_directory)/etc/theme" if [ -e "$website_file" ]; then cat "$website_file" else @@ -29,30 +43,47 @@ logo() { ╚══════╝╚═╝╚═╝░░╚══╝╚═════╝░░░░╚═╝░░░░╚════╝░╚═╝░░╚═╝╚══════╝""" } +generate_command() { + if [[ "$(readlink -f $(which x-terminal-emulator 2>/dev/null))" == */ptyxis* ]]; then + echo "ptyxis -- $1" + elif [[ "$(readlink -f $(which x-terminal-emulator 2>/dev/null))" == */gnome-terminal* ]]; then + echo "GNOME_TERMINAL_SCREEN='' gnome-terminal -- $1" + + else + echo "x-terminal-emulator -e $1" + fi +} + # Function to install an app install_app() { - local app_directory="$1" - local selected_app_name="$2" - local installed_file="$HOME/.linstore/installed" + local app_directory="$(get_app_directory "$1")" + local selected_app_name="$1" + local installed_file="$(linstore_directory)/installed" local temp_script=$(mktemp) + mkdir -p "$(linstore_directory)/installscripts" + + echo "#!/bin/bash" > "$temp_script" + echo "source \"$(api_script)\"" >> "$temp_script" + if [ -e "$app_directory/install" ]; then - echo "cd \"$app_directory\" && chmod +x install && ./install && echo \"$selected_app_name\" >> \"$installed_file\" && echo \"$selected_app_name is installed\" && cat install > \"$HOME/.linstore/installscripts/${selected_app_name}\"" >"$temp_script" + echo "cd \"$app_directory\" && chmod +x install && ./install && echo \"$selected_app_name\" >> \"$installed_file\" && echo \"$selected_app_name is installed\" && cat install > \"$(linstore_directory)/installscripts/${selected_app_name}\"" >> "$temp_script" else - local architecture=$(cat "$HOME/.linstore/architecture.txt") + local architecture=$(cat "$(linstore_directory)/architecture.txt") local install_script="install-$architecture" if [ -e "$app_directory/$install_script" ]; then - echo "cd \"$app_directory\" && chmod +x \"$install_script\" && ./\"$install_script\" && echo \"$selected_app_name\" >> \"$installed_file\" && echo \"$selected_app_name is installed\" && cat \"$install_script\" > \"$HOME/.linstore/installscripts/${selected_app_name}\"" >"$temp_script" + echo "cd \"$app_directory\" && chmod +x \"$install_script\" && ./\"$install_script\" && echo \"$selected_app_name\" >> \"$installed_file\" && echo \"$selected_app_name is installed\" && cat \"$install_script\" > \"$(linstore_directory)/installscripts/${selected_app_name}\"" >> "$temp_script" else if [ -e "$app_directory/packages" ]; then - echo "cd \"$app_directory\" && sudo apt update && sudo apt install \$(cat \"$app_directory/packages\") && echo \"$selected_app_name\" >> \"$installed_file\" && echo \"$selected_app_name is installed\" && cat packages > \"$HOME/.linstore/installscripts/${selected_app_name}\"" >"$temp_script" + echo "cd \"$app_directory\" && sudo apt update && sudo apt install \$(cat \"$app_directory/packages\") && echo \"$selected_app_name\" >> \"$installed_file\" && echo \"$selected_app_name is installed\" && cat packages > \"$(linstore_directory)/installscripts/${selected_app_name}\"" >> "$temp_script" else - echo "./api error 'Installation script not found for this architecture.'" + echo "error 'Installation script not found for this architecture.'" >> "$temp_script" fi fi fi - echo "x-terminal-emulator -e './api logo && ./api info \"Installing ${selected_app_name}\n\n\" && bash -c \"sudo echo && bash $temp_script\"'" + + generate_command "bash -c 'source \"$(api_script)\" && logo && information \"Installing ${selected_app_name}\n\n\" && sudo echo && bash \"$temp_script\"'" } get_installed_apps_from_piapps() { @@ -71,16 +102,14 @@ open_app() { fi } -# Function to install an app installation_script() { - local app_directory="$1" - local selected_app_name="$2" - local installed_file="$HOME/.linstore/installed" + local app_directory="$(get_app_directory "$1")" + local selected_app_name="$1" if [ -e "$app_directory/install" ]; then echo "install" else - local architecture=$(cat "$HOME/.linstore/architecture.txt") + local architecture=$(cat "$(linstore_directory)/architecture.txt") local install_script="install-$architecture" if [ -e "$app_directory/$install_script" ]; then @@ -97,29 +126,32 @@ installation_script() { # Function to uninstall an app uninstall_app() { - local app_directory="$1" - local selected_app_name="$2" - local uninstalled_file="$HOME/.linstore/uninstalled" + local app_directory="$(get_app_directory "$1")" + local selected_app_name="$1" + local uninstalled_file="$(linstore_directory)/uninstalled" local temp_script=$(mktemp) + echo "#!/bin/bash" > "$temp_script" + echo "source \"$(api_script)\"" >> "$temp_script" + if [ -e "$app_directory/uninstall" ]; then - echo "cd \"$app_directory\" && chmod +x uninstall && ./uninstall && echo \"$selected_app_name has been uninstalled\"" >"$temp_script" + echo "cd \"$app_directory\" && chmod +x uninstall && ./uninstall && echo \"$selected_app_name has been uninstalled\"" >> "$temp_script" else - local architecture=$(cat "$HOME/.linstore/architecture.txt") + local architecture=$(cat "$(linstore_directory)/architecture.txt") local uninstall_script="uninstall-$architecture" if [ -e "$app_directory/$uninstall_script" ]; then - echo "cd \"$app_directory\" && chmod +x \"$uninstall_script\" && ./\"$uninstall_script\" && echo \"$selected_app_name has been uninstalled\"" >"$temp_script" + echo "cd \"$app_directory\" && chmod +x \"$uninstall_script\" && ./\"$uninstall_script\" && echo \"$selected_app_name has been uninstalled\"" >> "$temp_script" else if [ -e "$app_directory/packages" ]; then - echo "cd \"$app_directory\" && sudo apt update && sudo apt remove \$(cat \"$app_directory/packages\") && echo \"$selected_app_name has been uninstalled\"" >"$temp_script" + echo "cd \"$app_directory\" && sudo apt update && sudo apt remove \$(cat \"$app_directory/packages\") && echo \"$selected_app_name has been uninstalled\"" >> "$temp_script" else - echo "./api error 'Uninstallation script not found for this architecture.'" >"$temp_script" + echo "error 'Uninstallation script not found for this architecture.'" >> "$temp_script" fi fi fi - echo "x-terminal-emulator -e './api logo && ./api info \"Uninstalling ${selected_app_name}\n\n\" && sudo echo && bash \"$temp_script\"'" + generate_command "bash -c 'source \"$(api_script)\" && logo && information \"Uninstalling ${selected_app_name}\n\n\" && sudo echo && bash \"$temp_script\"'" } # Function to search for apps @@ -130,18 +162,19 @@ search_apps() { query=$(GTK_THEME="${theme}" yad --title="Search Apps" --borders=10 --center --text="Enter query:" --entry \ --button="Cancel!gtk-cancel":1 --button="Search!edit-find":0) if [ -n "$query" ]; then - app_list=$(ls -w 1 ./apps | awk 'BEGIN {ORS="\n"} {print}') + app_list=$(ls -w 1 ./apps 2>/dev/null | awk 'BEGIN {ORS="\n"} {print}') num_apps=$(echo "$app_list" | wc -l) num_apps=$((num_apps)) echo "$num_apps" apps_found=() for app in ./apps/*; do + [ -e "$app" ] || continue app_name=$(basename "$app") if [[ "${app_name,,}" == *"${query,,}"* ]]; then app_icon="apps/$app_name/icon-24.png" app_category_file="$app/category" - app_category=$(head -n 1 "$app_category_file") + app_category=$(head -n 1 "$app_category_file" 2>/dev/null) apps_found+=("$app_icon" "$app_name" "in" "$app_category") fi done @@ -152,7 +185,7 @@ search_apps() { --column="in" --column="Category" --no-headers "${apps_found[@]}" --button="Exit!gtk-cancel":1 --button="View App!edit-find":0 &) if [ -n "$selected_category2" ]; then echo "$(echo ${selected_category2} | awk -F"|" '{print $2}' | sed 's/|//g')" > /tmp/tmpname - ./gui showdetails & + "$(linstore_directory)/gui" showdetails & fi else GTK_THEME="${theme}" yad --center --title="Search Results" --geometry=450x600+${x2}+${y2} \ @@ -160,20 +193,161 @@ search_apps() { --button="Retry!edit-find":1 --button="Exit!gtk-cancel":0 response=$? if [ $response -eq 1 ]; then - ./api search + "$(api_script)" search fi fi 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 + + local architecture=$(cat "$(linstore_directory)/architecture.txt" 2>/dev/null) + + for app_dir in "${1}"/*; do + app_name=$(basename "${app_dir}") + if [ -e "${1}/$app_name/category" ]; then + if [ -e "$app_dir/install" ] || [ -e "$app_dir/install-$architecture" ] \ + || [ -e "$HOME/pi-apps/apps/$app_name/install-$architecture" ] \ + || [ -e "$HOME/pi-apps/apps/$app_name/install" ]; then + echo "$app_name|$(cat "${1}/$app_name/category")" >> "${1}/app_categories" + fi + 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}') + app_dir="$HOME/pi-apps/apps/$app_name" + category=$(grep -r "$(echo "$line" | awk -F'|' '{print $2}')" etc/mapping | head -n1 | awk -F'|' '{print $2}') + if [ -e "$app_dir/install" ] || [ -e "$app_dir/install-$architecture" ] \ + || [ -e "$HOME/pi-apps/apps/$app_name/install-$architecture" ] \ + || [ -e "$HOME/pi-apps/apps/$app_name/install" ]; then + echo "$app_name|$category" >> "${1}/app_categories" + fi + 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 "$(linstore_directory)/etc/categories" +} + +get_apps_in_category() { + local category="$1" + grep "|$category$" "$(linstore_directory)/etc/categories" | cut -d'|' -f1 +} + +get_app_description() { + app_name="$1" + description_file="$(linstore_directory)/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="$(linstore_directory)/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 creator available." + fi +} + +get_app_website() { + app_name="$1" + website_file="$(linstore_directory)/apps/$app_name/website" + if [ -e "$website_file" ]; then + cat "$website_file" + else + echo "No website available." + fi +} + +get_app_directory() { + local app_name="$1" + if [ -d "$(linstore_directory)/apps/$app_name" ]; then + echo "$(linstore_directory)/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 +} + +# Stub for old package scripts +install_package(){ + install_packages "$@" +} + +remove_package(){ + echo "Removing $1..." + sudo apt remove "$1" -y > /dev/null 2>&1 +} + +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..." + "$(api_script)" info "Updating LinStore..." curl -s -L https://raw.githubusercontent.com/techguy16/LinStore/main/install | bash } buildinfo() { - echo "Update/commit $(git rev-parse --short HEAD) (\"$(git log --pretty='format:%Creset%s' --no-merges -1)\" - $(git log -1 --pretty=format:%an))" + echo "Update/commit $(git rev-parse --short HEAD 2>/dev/null) (\"$(git log --pretty='format:%Creset%s' --no-merges -1 2>/dev/null)\" - $(git log -1 --pretty=format:%an 2>/dev/null))" } error() { @@ -192,15 +366,43 @@ information() { printf '\033[1;104;30m INFO:\033[0;104m %s \033[0m\n' "$msg" >&2 } +export -f linstore_directory +export -f api_script +export -f theme_get +export -f logo +export -f generate_command +export -f install_app +export -f get_installed_apps_from_piapps +export -f open_app +export -f installation_script +export -f uninstall_app +export -f search_apps +export -f cache_categories +export -f get_categories +export -f get_apps_in_category +export -f get_app_description +export -f get_app_creator +export -f get_app_website +export -f get_app_directory +export -f install_packages +export -f install_package +export -f remove_package +export -f git_clone +export -f update +export -f buildinfo +export -f error +export -f warning +export -f information + # Main logic to handle command line arguments if [[ $1 == "search" ]]; then search_apps elif [[ $1 == "install" ]]; then - install_app "$2" "$3" + install_app "$2" elif [[ $1 == "whatscript" ]]; then - installation_script "$2" "$3" + installation_script "$2" elif [[ $1 == "uninstall" ]]; then - uninstall_app "$2" "$3" + uninstall_app "$2" elif [[ $1 == "logo" ]]; then logo elif [[ $1 == "error" ]]; then diff --git a/createapp b/createapp index f1349f2..f35bfc4 100755 --- a/createapp +++ b/createapp @@ -1,11 +1,11 @@ #!/bin/bash -APP_STORE_DIRECTORY="apps" -CATEGORIES_FILE="etc/categories" +APP_STORE_DIRECTORY="$(linstore_directory)/apps" +CATEGORIES_FILE="$(linstore_directory)/etc/categories" get_editor() { app_name="$1" - creator_file="etc/editor" + creator_file="$(linstore_directory)/etc/editor" if [ -e "$creator_file" ]; then cat "$creator_file" else @@ -15,15 +15,15 @@ get_editor() { select_category_pane() { category_list=() while read -r category; do - category_list+=("images/categories/$category.png" "$category" "$(cat "etc/categoryinfo/${category}")") + category_list+=("$(linstore_directory)/images/categories/$category.png" "$category" "$(cat "$(linstore_directory)/etc/categoryinfo/${category}")") done < "$CATEGORIES_FILE" selected_category=$(yad --title="Select Category" \ - --image="images/logo/logo-64.png" --image-on-top \ - --window-icon="images/logo/logo-64.png" --class="LinStore" \ + --image="$(linstore_directory)/images/logo/logo-64.png" --image-on-top \ + --window-icon="$(linstore_directory)/images/logo/logo-64.png" --class="LinStore" \ --text="Choose a category\nLinStore organises apps by category, which allows users to quickly find related apps easier.\nPlease choose a category for your app:" \ --field="Category:" \ - --width="525" --height="550" --center --on-top --borders=10 --columns=1 "${category_list[@]}" \ + --width="525" --height="550" --center --borders=10 --columns=1 "${category_list[@]}" \ --list --column="Icon:IMG" --column="Categories" --column="Description" --no-headers \ --button="Cancel!gtk-cancel":1 \ --button="Next!go-next":0 | awk -F '|' '{print $2}') @@ -44,8 +44,8 @@ create_new_app_pane() { app_directory="$APP_STORE_DIRECTORY" app_data=$(yad --form \ --title="Create New App" \ - --image="images/logo/logo-64.png" --image-on-top \ - --window-icon="images/logo/logo-64.png" \ + --image="$(linstore_directory)/images/logo/logo-64.png" --image-on-top \ + --window-icon="$(linstore_directory)/images/logo/logo-64.png" \ --class="LinStore" \ --text="App Details\nYour app needs information for LinStore to properly display it.\nEnter the following details for the new $(cat ${app_directory}/category) app:" \ --field=":LBL" "" \ @@ -63,7 +63,7 @@ create_new_app_pane() { --field="ARM 64-bit (aarch64):CHK" "" \ --field=":LBL" "" \ --field="Separate or combined install scripts?:CB" 'Combined (all architectures in one)!Separate' \ - --width="525" --height="550" --center --on-top --borders=10 --separator="|" \ + --width="525" --height="550" --center --borders=10 --separator="|" \ --button="Cancel!gtk-cancel":1 \ --button="Next!go-next":0) @@ -99,12 +99,12 @@ create_new_app_pane() { #icon_file=$(yad --file-selection --title="Select Icon for App" --width="525" --height="550" --center --on-top) assets_data=$(yad --form \ --title="Create New App" \ - --image="images/logo/logo-64.png" --image-on-top \ - --window-icon="images/logo/logo-64.png" --class="LinStore" \ + --image="$(linstore_directory)/images/logo/logo-64.png" --image-on-top \ + --window-icon="$(linstore_directory)/images/logo/logo-64.png" --class="LinStore" \ --text="App Assets\nYour app needs assets in LinStore, which is currently limited to the app's logo/icon.\nSelect these assets here:" \ --field=":LBL" "" \ --field="Icon/logo:SFL" "" \ - --width="525" --height="550" --center --on-top --borders=10 --separator="|" \ + --width="525" --height="550" --center --borders=10 --separator="|" \ --button="Cancel!gtk-cancel":1 \ --button="Next!go-next":0) @@ -120,63 +120,78 @@ create_new_app_pane() { convert "$icon_file" -resize 24x24 "$app_directory/icon-24.png" convert "$icon_file" -resize 16x16 "$app_directory/icon-16.png" fi - + + # Create or update the install scripts based on user preferences + if [[ "$separate_scripts" == "Combined (all architectures in one)" ]]; then + touch "$app_directory/install" & + else + if [ "$install_x64" == "TRUE" ]; then + touch "$app_directory/install-x64" & + fi + if [ "$install_x86" == "TRUE" ]; then + touch "$app_directory/install-x86" & + fi + if [ "$install_32" == "TRUE" ]; then + touch "$app_directory/install-32" & + fi + if [ "$install_64" == "TRUE" ]; then + touch "$app_directory/install-64" & + fi + fi + + touch "$app_directory/uninstall" & + + edit_scripts_pane "$app_directory" +} + +edit_scripts_pane() { + app_directory="$1" + editor=$(get_editor) + buttons=() + for file in "$app_directory"/*; do + [ -f "$file" ] || continue + if [[ "$(basename "$file")" == "install"* ]]; then + buttons+=("--field= $(basename "$file")!images/button/install.png:BTN" "$editor \"$file\"") + elif [[ "$(basename "$file")" == "uninstall"* ]]; then + buttons+=("--field= $(basename "$file")!images/button/uninstall.png:BTN" "$editor \"$file\"") + fi + done + yad --form \ --title="Create New App" \ - --image="images/logo/logo-64.png" --image-on-top \ - --window-icon="images/logo/logo-64.png" --class="LinStore" \ - --text="Installer Scripts\nYour app has been created!" \ + --image="$(linstore_directory)/images/logo/logo-64.png" --image-on-top \ + --window-icon="$(linstore_directory)/images/logo/logo-64.png" --class="LinStore" \ + --text="Edit App Scripts\nEdit your app's install and uninstall scripts." \ --field=":LBL" "" \ - --field="You now need to write an Installer and an Uninstaller script. These are the scripts executed when users click \"Install\" and \"Uninstall\" in LinStore.\n\nIf you would like to create these now, press 'Next'. Else, press 'Cancel'.:LBL" "" \ - --width="525" --height="550" --center --on-top --borders=10 --separator="|" \ + --field="Listed below are the scripts used by LinStore when installing or uninstalling your app. Click on one to create or edit it.:LBL" "" \ + "${buttons[@]}" \ + --width="525" --height="550" --center --borders=10 --separator="|" \ --button="Cancel!gtk-cancel":1 \ - --button="Next!go-next":0 > /dev/null 2>&1 + --button="Next!go-next":0 > /dev/null 2>&1 - # Create or update the install scripts based on user preferences if [ $? -eq 0 ]; then - if [[ "$separate_scripts" == "Combined (all architectures in one)" ]]; then - gedit "$app_directory/install" & - else - if [ "$install_x64" == "TRUE" ]; then - gedit "$app_directory/install-x64" & - fi - if [ "$install_x86" == "TRUE" ]; then - gedit "$app_directory/install-x86" & - fi - if [ "$install_32" == "TRUE" ]; then - gedit "$app_directory/install-32" & - fi - if [ "$install_64" == "TRUE" ]; then - gedit "$app_directory/install-64" & - fi - fi - - gedit "$app_directory/uninstall" - wait - elif [ $? -eq 252 ]; then - echo $? + yad --form \ + --title="Create New App" \ + --image="$(linstore_directory)/images/logo/logo-64.png" --image-on-top \ + --window-icon="$(linstore_directory)/images/logo/logo-64.png" --class="LinStore" \ + --text="Thank you!\nThank you for using LinStore's app creation wizard." \ + --field=":LBL" "" \ + --field="Next Steps:\nSubmit your app for addition to LinStore's app library. You can do this by 'zipping' the new app's directory and uploading it to an issue at our GitHub.\n\nIf you do not wish to do so, you can still distribute your app's zip file by specifying to your users to use LinStore's 'Import App' function.:LBL" "" \ + --width="525" --height="550" --center --borders=10 --separator="|" \ + --button="Exit!window-close":0 > /dev/null 2>&1 fi - - yad --form \ - --title="Create New App" \ - --image="images/logo/logo-64.png" --image-on-top \ - --window-icon="images/logo/logo-64.png" --class="LinStore" \ - --text="Thank you!\nThank you for using LinStore's app creation wizard." \ - --field=":LBL" "" \ - --field="Next Steps:\nSubmit your app for addition to LinStore's app library. You can do this by 'zipping' the new app's directory and uploading it to an issue at our GitHub.\n\nIf you do not wish to do so, you can still distribute your app's zip file by specifying to your users to use LinStore's 'Import App' function.:LBL" "" \ - --width="525" --height="550" --center --on-top --borders=10 --separator="|" \ - --button="Exit!window-close":0 > /dev/null 2>&1 + } welcome() { yad --form \ --title="Create New App" \ - --image="images/logo/logo-64.png" --image-on-top \ - --window-icon="images/logo/logo-64.png" --class="LinStore" \ + --image="$(linstore_directory)/images/logo/logo-64.png" --image-on-top \ + --window-icon="$(linstore_directory)/images/logo/logo-64.png" --class="LinStore" \ --text="App Creator\nWelcome to the LinStore's app creator!" \ --field=":LBL" "" \ --field="What is this?\nThis is a wizard that will guide you through the necessary steps in order to create an app to be displayed in LinStore.\n\nIf you're ready, press 'Next'.\nIf you got here by accident, press 'Cancel'.:LBL" "" \ - --width="525" --height="550" --center --on-top --borders=10 --separator="|" \ + --width="525" --height="550" --center --borders=10 --separator="|" \ --button="Cancel!gtk-cancel":1 \ --button="Next!go-next":0 > /dev/null 2>&1 if [ $? -eq 0 ]; then @@ -190,13 +205,13 @@ import_zip_file() { #import_file=$(yad --file-selection --title="Select Zip File to Import" --height="550" --width="525" --center --on-top) import_file=$(yad --form \ --title="Import App" \ - --image="images/logo/logo-64.png" --image-on-top \ - --window-icon="images/logo/logo-64.png" --class="LinStore" \ + --image="$(linstore_directory)/images/logo/logo-64.png" --image-on-top \ + --window-icon="$(linstore_directory)/images/logo/logo-64.png" --class="LinStore" \ --text="Import an app\nImport an app packaged as a ZIP into LinStore." \ --field=":LBL" "" \ --field="Some app developers distribute ZIP files to let you import into LinStore.\n\nTo import such a ZIP file, select it below and we'll import it for you.:LBL" "" \ --field="ZIP File: :SFL" "" \ - --width="525" --height="550" --center --on-top --borders=10 --separator="|" \ + --width="525" --height="550" --center --borders=10 --separator="|" \ --button="Cancel!gtk-cancel":1 \ --button="Next!go-next":0 | awk -F '|' '{print $3}') @@ -210,8 +225,8 @@ import_zip_file() { yad --form \ --title="Import App" \ - --image="images/logo/logo-64.png" --image-on-top \ - --window-icon="images/logo/logo-64.png" --class="LinStore" \ + --image="$(linstore_directory)/images/logo/logo-64.png" --image-on-top \ + --window-icon="$(linstore_directory)/images/logo/logo-64.png" --class="LinStore" \ --text="Success!\nYour app has been successfully imported into LinStore." \ --field=":LBL" "" \ --field="You should now be able to find the app in the list of available apps!:LBL" "" \ diff --git a/etc/tools/LinStore.zip b/etc/tools/LinStore.zip new file mode 100644 index 0000000..d572adf Binary files /dev/null and b/etc/tools/LinStore.zip differ diff --git a/gui b/gui index 87bc285..bb7ab3a 100755 --- a/gui +++ b/gui @@ -9,6 +9,12 @@ YAD_COMMAND="yad" YAD_FLAGS="" ACCENT="green" +export ACCENT + +pipe="$(mktemp -u)" +mkfifo $pipe +export pipe +trap "rm -f $pipe" EXIT #pwd if ! command -v "$YAD_COMMAND" &>/dev/null; then @@ -16,12 +22,17 @@ if ! command -v "$YAD_COMMAND" &>/dev/null; then exit 1 fi -if [ -f "gui" ] || [ -f "createapp" ] || [ -f "settings" ]; then +if [ -e "$HOME/.linstore/directory" ]; then + cd "$(cat "$HOME/.linstore/directory")" +elif [ -f "gui" ] || [ -f "api" ]; then cd . else cd ~/.linstore fi +source api +cd "$(linstore_directory)" + if [[ $(xrandr --current) =~ "connected primary" ]]; then #echo "Dual monitor setup, placing on primary monitor" resolution=$(xrandr --current | grep " connected primary" | awk '{print $4}' | cut -d'+' -f1) @@ -42,31 +53,31 @@ detect_and_write_architecture() { mkdir -p ~/.linstore case "$(uname -m)" in x86_64) - echo "x64" >~/.linstore/architecture.txt + echo "x64" > "$(linstore_directory)/architecture.txt" ;; i686) - echo "x86" >~/.linstore/architecture.txt + echo "x86" > "$(linstore_directory)/architecture.txt" ;; armv7l) - echo "32" >~/.linstore/architecture.txt + echo "32" > "$(linstore_directory)/architecture.txt" ;; aarch64) - echo "64" >~/.linstore/architecture.txt + echo "64" > "$(linstore_directory)/architecture.txt" ;; *) - echo "Unknown architecture" >~/.linstore/architecture.txt + echo "Unknown architecture" > "$(linstore_directory)/architecture.txt" ;; esac } -if [ -e "etc/accent" ]; then - ACCENT="$(cat etc/accent)" +if [ -e "$(linstore_directory)/etc/accent" ]; then + ACCENT="$(cat "$(linstore_directory)/etc/accent")" if [[ "$ACCENT" == "" ]]; then ACCENT="green" fi fi list_piapps() { - piapps_file="etc/pi-apps-import" + piapps_file="$(linstore_directory)/etc/pi-apps-import" if [ -e "$piapps_file" ]; then cat "$piapps_file" else @@ -74,98 +85,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" - 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 @@ -181,15 +100,11 @@ theme=$(theme_get) multi_install() { all_apps_list=() - 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 - app_icon="apps/$app_name/icon-24.png" - all_apps_list+=("FALSE") - all_apps_list+=("$app_icon") - all_apps_list+=("$app_name") - fi - done + while IFS= read -r app_name; do + app_name=$(echo "$app_name" | awk -F'|' '{print $1}') + app_icon="$(get_app_directory "$app_name")/icon-24.png" + all_apps_list+=("FALSE" "$app_icon" "$app_name") + done < "$(linstore_directory)/apps/app_categories" APPS=$(GTK_THEME="${theme}" GDK_BACKEND=x11 $YAD_COMMAND --text "Multi Installer\nInstall multiple apps at once" --geometry=600x${APP_STORE_HEIGHT} --center --columns="3" \ --list --checklist --image="images/logo/logo-64.png" --window-icon="images/logo/logo-64.png" --image-on-top --title "LinStore" --column="Select":chk --column "Icon:IMG" --column "Apps" \ @@ -200,10 +115,11 @@ multi_install() { if [[ "$APPS" != "" ]]; then list="" while IFS= read -r line; do + echo "Selected: $line" list+="$(echo -e "$line" | awk -F "|" '{print $3}')" list+=$'\n' done <<< "$APPS" - ./manage multi-install "$list" + "$(linstore_directory)/manage" multi-install "$list" fi fi } @@ -222,32 +138,32 @@ 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") - if [ -e "$HOME/.linstore/installscripts/$selected_app_name" ]; then + if [ -e "$(linstore_directory)/installscripts/$selected_app_name" ]; then installed="true" else installed="false" fi - local install_command=$(./api install "$app_directory" "$selected_app_name") - local uninstall_command=$(./api uninstall "$app_directory" "$selected_app_name") + local install_command=$("$(api_script)" install "$selected_app_name") + local uninstall_command=$("$(api_script)" uninstall "$selected_app_name") - local open_command=$(./api open "$app_directory") + local open_command=$("$(api_script)" open "$app_directory") buttons=() + # Create a temporary script for the commands + temp_script=$(mktemp) + chmod +x "$temp_script" if [[ "$installed" == "true" ]]; then displayName="${selected_app_name} (installed)" buttonText="Uninstall" buttonImage="images/button/uninstall.png" - # Create a temporary script for the commands - temp_script=$(mktemp) - echo "$uninstall_command && rm -rf \"$HOME/.linstore/installscripts/$selected_app_name\"" >"$temp_script" - chmod +x "$temp_script" + echo "$uninstall_command && rm -rf \"$(linstore_directory)/installscripts/$selected_app_name\"" >"$temp_script" buttonCommand="bash -c 'bash $temp_script; rm $temp_script'" if [[ "$open_command" != "" ]]; then buttons+=("--button=Open!system-run:$open_command") @@ -256,7 +172,8 @@ app_details_page() { displayName="${selected_app_name} (not installed)" buttonText="Install" buttonImage="images/button/install.png" - buttonCommand="$install_command" + echo "$install_command" >"$temp_script" + buttonCommand="bash -c 'bash $temp_script; rm $temp_script'" fi if [[ "$open" != "" ]]; then @@ -279,113 +196,94 @@ app_details_page() { rm -f /tmp/description.tmp } -show_apps_in_category() { - while true; do - 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 - app_icon="apps/$app_name/icon-24.png" - formatted_apps+=("$app_icon") - if [ -e "$HOME/.linstore/installscripts/$app_name" ]; then - formatted_apps+=("$app_name") - else - formatted_apps+=("$app_name") - fi - fi - done - 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") - fi - done - fi - - GTK_THEME="${theme}" GDK_BACKEND=x11 $YAD_COMMAND --text "$title" --geometry=${APP_STORE_WIDTH}x${APP_STORE_HEIGHT}+${categoryPos}+${categoryPosY} --center --columns="2" \ - --list --image="images/logo/logo-64.png" --window-icon="images/logo/logo-64.png" --image-on-top --title "LinStore" --column "Icon:IMG" --column "Apps" --class="LinStore" \ - --button="Back"!images/button/back.png!:4 --separator="\n" --markup "${formatted_apps[@]}" --no-headers \ - --css="span{fgcolor:green;}" --select-action='bash -c "./gui showdetails \"%s\"" &'#> /dev/null 2>&1 +update_fifo() { + output=() + if [[ "$2" == "Back" ]]; then + selected_item="" + else + selected_item="$2" + fi - button_clicked=$? - if [ $button_clicked -eq 4 ]; then - show_app_store - break - fi + if [[ "$selected_item" == "" ]]; then + echo -e "\f" >> "$pipe" + sorted_categories=$(printf '%s\n' "$(get_categories)" | sort) + + output+=("images/categories/All Apps.png" "All Apps") + while IFS= read -r category; do + category_icon="images/categories/$category.png" # Path to category icons + output+=("$category_icon" "$category") + done <<<"$sorted_categories" + elif [[ "$selected_item" == "All Apps" ]] || grep -q "$selected_item" "$(linstore_directory)/etc/categories"; then + echo -e "\f" >> "$pipe" + output+=("$(linstore_directory)/images/button/back.png") + output+=("Back") + + while IFS= read -r line; do + [[ $(echo "$line" | awk -F'|' '{print $2}') == "$selected_item" ]] ||\ + [[ "$selected_item" == "All Apps" ]] || continue + app_name=$(echo "$line" | awk -F'|' '{print $1}') + app_icon="$(get_app_directory "$app_name")/icon-24.png" + if [[ ! -f "$app_icon" ]]; then + app_icon="application-x-executable" + fi + output+=("$app_icon") + if [ -e "$(linstore_directory)/installscripts/$app_name" ]; then + output+=("$app_name") + else + output+=("$app_name") + fi + done < "$(linstore_directory)/apps/app_categories" + else + "$(linstore_directory)/gui" showdetails "$selected_item" + return + fi - show_app_store - break + for item in "${output[@]}"; do + echo "$item" >> "$pipe" done } +export -f update_fifo 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) - - list_items=() - list_items=("images/categories/All Apps.png" "All Apps") - while IFS= read -r category; do - category_icon="images/categories/$category.png" # Path to category icons - list_items+=("$category_icon") - list_items+=("$category") - done <<<"$sorted_categories" - # Fetching a random line from the announcements file random_announcement=$(shuf -n 1 etc/announcements) - - # Search function - - selected_category_raw=$(GTK_THEME="${theme}" GDK_BACKEND=x11 $YAD_COMMAND --text "$random_announcement" \ - --geometry=${APP_STORE_WIDTH}x${APP_STORE_HEIGHT}+${categoryPos}+${categoryPosY} --center --columns="3" \ - "${list_items[@]}" --class="LinStore" \ + update_fifo "" & + + GTK_THEME="${theme}" GDK_BACKEND=x11 $YAD_COMMAND --text "$random_announcement" \ + --geometry=${APP_STORE_WIDTH}x${APP_STORE_HEIGHT}+${categoryPos}+${categoryPosY} --center \ + --class="LinStore" --select-action="bash -c "\""update_fifo %s"\""" --dclick-action="bash -c "\""update_fifo %s"\""" \ --list --image="images/logo/logo-64.png" --window-icon="images/logo/logo-64.png" --image-on-top --title "$APP_STORE_NAME" --column "Icon:IMG" \ --column "Category" --button "!images/button/search.png"!"Search":"bash -c './api search' &" \ - --button "!images/button/update.png"!"Updates":"bash -c './update' &" --button "!images/button/settings.png"!"Settings":"bash -c './settings' &" \ - --no-headers --item-height="$welcome_height" --timeout=0 --no-close) + --button "!images/button/update.png"!"Updates":"bash -c './update' &" --button "!images/button/settings.png"!"Settings":"bash -c './settings'" \ + --no-headers --timeout=0 --no-close < <(tail -f $pipe 2>/dev/null) exval=$? - ./api info "Exit value: ${exval}" - selected_category="${selected_category_raw//|/}" + "$(api_script)" info "Exit value: ${exval}" if [ "$exval" == "44" ]; then - ./api search && show_app_store - elif [ "$exval" -eq "143" ]; then - pkill -f "yad*" > /dev/null 2>&1 + "$(api_script)" search && show_app_store elif [ "$exval" -eq "252" ]; then pkill -f "yad*" > /dev/null 2>&1 - elif [ -n "$selected_category" ]; then - show_apps_in_category "$selected_category" & + exit 1 fi } +if [ ! -e apps/app_categories ]; then + cache_categories "apps" "$(list_piapps)" +fi + if [[ $1 == "" ]]; then - ./api logo - ./api buildinfo + "$(api_script)" logo + "$(api_script)" buildinfo echo "" use_piapps=$(list_piapps) - ./api warning "Is LinStore able to use Pi-Apps' library? ${use_piapps}" + "$(api_script)" warning "Is LinStore able to use Pi-Apps' library? ${use_piapps}" fi if [[ $1 == "showdetails" ]]; then if [ -e /tmp/tmpname ]; then app_details_page "$(cat /tmp/tmpname && rm -r /tmp/tmpname)" else - app_details_page "$(echo $2 | awk -F"'" '{print $4}')" + app_details_page "$2" fi elif [[ $1 == "multi-install" ]]; then multi_install diff --git a/images/screenshots/2.png b/images/screenshots/2.png index 88767a1..c8a1fef 100644 Binary files a/images/screenshots/2.png and b/images/screenshots/2.png differ diff --git a/install b/install index bf443ab..68b8d95 100755 --- a/install +++ b/install @@ -38,16 +38,22 @@ information() { echo -e "\033[1;104m\033[30m INFO:\033[0;104m $1 \033[0m" 1>&2 } -if ! command -v git &>/dev/null; then - echo "Git is not installed. Please install Git and rerun the installation." - missing_dependencies=true -fi +missing_dependencies=false + +dependencies=(yad wmctrl convert xdotool git wget) + +for dependency in "${dependencies[@]}"; do + if ! command -v "$dependency" >/dev/null 2>&1; then + missing_dependencies=true + break + fi +done -if ! command -v yad wmctrl convert xdotool &>/dev/null; then +if [[ "$missing_dependencies" == true ]]; then warning "Various dependencies required for LinStore are not installed." information "Installing dependencies..." sudo apt update > /dev/null 2>&1 - if sudo apt install yad wmctrl imagemagick xdotool -y > /dev/null 2>&1; then + if sudo apt install yad wmctrl imagemagick xdotool git wget -y > /dev/null 2>&1; then missing_dependencies=false else error "Cannot continue, exiting." @@ -55,6 +61,24 @@ if ! command -v yad wmctrl convert xdotool &>/dev/null; then fi fi +# Ubuntu 26+ requires yad to be downgraded for LinStore to display properly +if [[ "$(cat /etc/os-release | grep VERSION_ID | tr -d 'VERSION_ID="' | awk -F'.' '{print $1}')" -ge 26 ]]; then + information "Downgrading yad to supported version..." + if [[ "$(uname -m)" == "x86_64" ]]; then + package_url="http://archive.ubuntu.com/ubuntu/pool/universe/y/yad/yad_0.40.0-1build3_amd64.deb" + elif [[ "$(uname -m)" == "aarch64" ]]; then + package_url="https://ports.ubuntu.com/pool/universe/y/yad/yad_0.40.0-1build3_arm64.deb" + else + warning "Unsupported architecture for downgrade. LinStore may break." + fi + + if [[ -n "$package_url" ]]; then + wget --no-check-certificate "$package_url" -O /tmp/package.deb > /dev/null 2>&1 + sudo dpkg -i /tmp/package.deb > /dev/null 2>&1 + rm -r /tmp/package.deb + fi +fi + if [ "$missing_dependencies" = true ]; then exit 1 fi @@ -93,16 +117,18 @@ cp -r "$temp_dir"/* "$install_dir" cd "$install_dir" chmod +x * chmod +x "gui" +echo "$HOME/.linstore" > "$HOME/.linstore/directory" rm -rf "$temp_dir" # Clean up temporary directory # Create a bin directory if it doesn't exist -if [ ! -e /usr/local/bin/install_package ]; then - sudo mkdir -p /usr/local/bin +# LinStore no longer uses system-wide scripts +# if [ ! -e /usr/local/bin/install_package ]; then +# sudo mkdir -p /usr/local/bin # Copy files to /usr/local/bin - information "Copying executable files to /usr/local/bin..." - sudo cp "$install_dir"/etc/tools/*_package /usr/local/bin/ -fi +# information "Copying executable files to /usr/local/bin..." +# sudo cp "$install_dir"/etc/tools/*_package /usr/local/bin/ +# fi # Create a desktop shortcut for GUI information "Creating shortcuts..." diff --git a/manage b/manage index 36e2d36..27dccfb 100755 --- a/manage +++ b/manage @@ -3,26 +3,28 @@ # Designed for compatibility with Pi-Apps # Very basic, sorry! +source api + install() { - local install_command=$(./api install "apps/$1" "$1") + local install_command=$("$(api_script)" install "$1") bash -c "$install_command" } multi_install() { while IFS= read -r line; do - local install_command=$(./api install "apps/$line" "$line") + local install_command=$("$(api_script)" install "$line") bash -c "$install_command" done <<< "$1" } uninstall() { - local uninstall_command=$(./api uninstall "apps/$1" "$1") + local uninstall_command=$("$(api_script)" uninstall "$1") bash -c "$uninstall_command" } multi_uninstall() { while IFS= read -r line; do - local uninstall_command=$(./api uninstall "apps/$line" "$line") + local uninstall_command=$("$(api_script)" uninstall "$line") bash -c "$uninstall_command" done <<< "$1" } diff --git a/settings b/settings index f6552b9..bd5f56c 100755 --- a/settings +++ b/settings @@ -1,16 +1,18 @@ #!/bin/bash -APP_STORE_DIRECTORY="apps" -CATEGORIES_FILE="etc/categories" +source api + +APP_STORE_DIRECTORY="$(linstore_directory)/apps" +CATEGORIES_FILE="$(linstore_directory)/etc/categories" THEMES_DIRECTORY="/usr/share/themes" -THEMES_FILE="etc/theme" +THEMES_FILE="$(linstore_directory)/etc/theme" show_settings() { pkill -f "yad.*" - selectedtheme=$(cat "etc/theme" 2>/dev/null) - if [[ ! -f "etc/theme" ]]; then - ./api error "etc/theme does not exist" + selectedtheme=$(cat "$(linstore_directory)/etc/theme" 2>/dev/null) + if [[ ! -f "$(linstore_directory)/etc/theme" ]]; then + "$(api_script)" error "$(linstore_directory)/etc/theme does not exist" fi #echo "$selectedtheme" if [[ -z "$selectedtheme" || "$selectedtheme" == " " ]]; then @@ -32,10 +34,10 @@ show_settings() { theme_string+="$theme" done - selectededitor=$(cat "etc/editor" 2>/dev/null | sed -r 's/ \(currently selected\)//g') + selectededitor=$(cat "$(linstore_directory)/etc/editor" 2>/dev/null | sed -r 's/ \(currently selected\)//g') #echo "$selectededitor" - if [[ ! -f "./etc/editor" ]]; then - ./api error "etc/editor does not exist" + if [[ ! -f "$(linstore_directory)/etc/editor" ]]; then + "$(api_script)" error "$(linstore_directory)/etc/editor does not exist" fi if [[ -z "$selectededitor" || "$selectededitor" == " " ]]; then texteditors="System Default" @@ -45,8 +47,8 @@ show_settings() { texteditors+="!Visual Studio Code!Geany!Gedit!Mousepad!VSCodium" accents="" - if [ -e "etc/accent" ]; then - ACCENT=$(cat etc/accent) + if [ -e "$(linstore_directory)/etc/accent" ]; then + ACCENT=$(cat "$(linstore_directory)/etc/accent") if [[ "$ACCENT" == "" ]]; then accents+="Default!" else @@ -58,9 +60,9 @@ show_settings() { fi accents+="red!orangered!orange!yellow!limegreen!green!teal!lightblue!blue!purple!pink!grey" - import_piapps_file=$(cat "etc/pi-apps-import" 2>/dev/null) - if [[ ! -f "./etc/pi-apps-import" ]]; then - ./api error "etc/pi-apps-import does not exist" + import_piapps_file=$(cat "$(linstore_directory)/etc/pi-apps-import" 2>/dev/null) + if [[ ! -f "$(linstore_directory)/etc/pi-apps-import" ]]; then + "$(api_script)" error "$(linstore_directory)/etc/pi-apps-import does not exist" fi #echo "$selectededitor" if [[ -z "$import_piapps_file" || "$import_piapps_file" == " " ]]; then @@ -69,9 +71,9 @@ show_settings() { import_piapps="${import_piapps_file}" fi - express_updates_file=$(cat "etc/express-updates" 2>/dev/null) - if [[ ! -f "./etc/express-updates" ]]; then - ./api error "etc/express-updates does not exist" + express_updates_file=$(cat "$(linstore_directory)/etc/express-updates" 2>/dev/null) + if [[ ! -f "$(linstore_directory)/etc/express-updates" ]]; then + "$(api_script)" error "$(linstore_directory)/etc/express-updates does not exist" fi #echo "$selectededitor" if [[ -z "$express_updates_file" || "$express_updates_file" == " " ]]; then @@ -111,13 +113,13 @@ show_settings() { echo "$selected_text_editor" # Echoing to the 'etc/editor' file based on the selected text editor case "$selected_text_editor" in - "System Default") echo "xdg-open" >"etc/editor" ;; - "Visual Studio Code") echo "code" >"etc/editor" ;; - "Geany") echo "geany" >"etc/editor" ;; - "Gedit") echo "gedit" >"etc/editor" ;; - "Mousepad") echo "mousepad" >"etc/editor" ;; - "VSCodium") echo "codium" >"etc/editor" ;; - *) echo "$selected_text_editor" >"etc/editor" ;; + "System Default") echo "xdg-open" >"$(linstore_directory)/etc/editor" ;; + "Visual Studio Code") echo "code" >"$(linstore_directory)/etc/editor" ;; + "Geany") echo "geany" >"$(linstore_directory)/etc/editor" ;; + "Gedit") echo "gedit" >"$(linstore_directory)/etc/editor" ;; + "Mousepad") echo "mousepad" >"$(linstore_directory)/etc/editor" ;; + "VSCodium") echo "codium" >"$(linstore_directory)/etc/editor" ;; + *) echo "$selected_text_editor" >"$(linstore_directory)/etc/editor" ;; esac selected_theme=$(echo "$fixed_settings" | awk -F '|' '{print $2}') @@ -133,15 +135,16 @@ show_settings() { accent_colour=$(echo "$fixed_settings" | awk -F '|' '{print $4}' | sed -r 's/ \(currently selected\)//g') case "$accent_colour" in - "Default") echo "green" >"etc/accent" ;; - *) echo "$accent_colour" >"etc/accent" ;; + "Default") echo "green" >"$(linstore_directory)/etc/accent" ;; + *) echo "$accent_colour" >"$(linstore_directory)/etc/accent" ;; esac import_from_piapps=$(echo "$fixed_settings" | awk -F '|' '{print $5}') - echo $import_from_piapps > "etc/pi-apps-import" + echo $import_from_piapps > "$(linstore_directory)/etc/pi-apps-import" + cache_categories "apps" "$(cat "$(linstore_directory)/etc/pi-apps-import" 2> /dev/null || echo FALSE)" express_updates=$(echo "$fixed_settings" | awk -F '|' '{print $6}') - echo $express_updates > "etc/express-updates" + echo $express_updates > "$(linstore_directory)/etc/express-updates" ./gui elif [[ $yad_ret -eq 252 ]]; then diff --git a/update b/update index a823a90..e81433b 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 @@ -11,8 +13,8 @@ vertical=$(echo $resolution | cut -d'x' -f2) check_for_updates() { #kill $(pgrep -f "title=App Details") - local repository_path="./apps" - local installed_scripts_path="$HOME/.linstore/installscripts" + local repository_path="$(linstore_directory)/apps" + local installed_scripts_path="$(linstore_directory)/installscripts" local updates=() mkdir -p "$installed_scripts_path" @@ -23,16 +25,19 @@ check_for_updates() { sleep 1 # Clean up previous installation - rm -rf ~/.linstore/tmp + rm -rf "$(linstore_directory)/tmp" echo "# Cloning repository" - git clone https://github.com/techguy16/linstore ~/.linstore/tmp > /dev/null 2>&1 + git clone https://github.com/techguy16/linstore "$(linstore_directory)/tmp" > /dev/null 2>&1 sleep 1 echo "# Moving new app installation scripts" - rm -rf ./apps - mv ~/.linstore/tmp/apps ./apps + rm -rf "$(linstore_directory)/apps" + mv "$(linstore_directory)/tmp/apps" "$(linstore_directory)/apps" sleep 1 + echo '# Update app cache' + cache_categories "apps" "$(cat "$(linstore_directory)/etc/pi-apps-import" 2> /dev/null || echo FALSE)" + # Clean up # rm -rf ~/.linstore/tmp echo "# Finished" @@ -43,16 +48,16 @@ check_for_updates() { local fileupdates="" for file in gui api createapp settings update; do - if diff "./$file" "$HOME/.linstore/tmp/$file" > /dev/null 2>&1; then - ./api info "No updates available for $file" + if diff "$(linstore_directory)/$file" "$(linstore_directory)/tmp/$file" > /dev/null 2>&1; then + "$(api_script)" info "No updates available for $file" else - ./api warning "Update available for $file" + "$(api_script)" warning "Update available for $file" fileupdates+="$file, " fi done if [ "$fileupdates" != "" ]; then - updates+=(TRUE "images/logo/logo-16.png" "LinStore ($(echo $fileupdates | sed 's/[[:space:]]*$//' | sed 's/,$//'))") + updates+=(TRUE "$(linstore_directory)/images/logo/logo-16.png" "LinStore ($(echo $fileupdates | sed 's/[[:space:]]*$//' | sed 's/,$//'))") fi for installed_script in "$installed_scripts_path"/*; do @@ -64,7 +69,7 @@ check_for_updates() { fi app_directory="$repository_path/$app_name" - app_script=$(./api whatscript "$app_directory" "$app_name") + app_script=$("$(api_script)" whatscript "$app_directory" "$app_name") script="$app_directory/$app_script" if [ -d "$app_directory" ]; then @@ -89,14 +94,14 @@ check_for_updates() { buttons_noupd=() pos=$(wmctrl -lG | grep "LinStore$" | awk '{print $3,$4}') if xdotool search --name "^LinStore$" >/dev/null 2>&1; then - ./api info "Running with LinStore GUI open" + "$(api_script)" info "Running with LinStore GUI open" buttons+=("--button=Recheck Updates!edit-find:2") buttons+=("--button=Update Selected:0") buttons_noupd+=("--button=Recheck Updates!edit-find:2") buttons_noupd+=("--button=Finish!go-next:3") x2=$((horizontal / 2 - 65)) else - ./api info "Running without LinStore open" + "$(api_script)" info "Running without LinStore open" buttons+=("--button=Return to LinStore!edit-undo:1") buttons+=("--button=Recheck Updates!edit-find:2") buttons+=("--button=Update Selected!view-refresh:0") @@ -126,11 +131,12 @@ check_for_updates() { app_name=$(echo "$selected" | cut -d '|' -f 3 | sed 's/<\/\?b>//g') echo "Updating selected: $app_name" if [[ "$(echo $app_name | awk -F" " '{print $1}')" == "LinStore" ]]; then - bash -c "x-terminal-emulator -e './api update'" + + bash -c "$(generate_command "./api update")" else - ./api info "Updating app: $app_name" + "$(api_script)" info "Updating app: $app_name" app_directory="$repository_path/$app_name" - install=$(./api install "$app_directory" "$app_name") + install=$("$(api_script)" install "$app_directory" "$app_name") bash -c "${install}" fi fi