diff --git a/bin/omarchy-webapp-install b/bin/omarchy-webapp-install index a75a32883e..9a0486bc8d 100755 --- a/bin/omarchy-webapp-install +++ b/bin/omarchy-webapp-install @@ -1,14 +1,16 @@ #!/bin/bash -if [ "$#" -ne 3 ]; then +if [ "$#" -ne 4 ]; then echo -e "\e[32mLet's create a new web app you can start with the app launcher.\n\e[0m" APP_NAME=$(gum input --prompt "Name> " --placeholder "My favorite web app") APP_URL=$(gum input --prompt "URL> " --placeholder "https://example.com") ICON_URL=$(gum input --prompt "Icon URL> " --placeholder "See https://dashboardicons.com (must use PNG!)") + PROFILE=$(gum input --prompt "Separate Profile?> " --placeholder "Leave it blank for a shared profile, or type "YES" for a separate profile (multiple instances)") else APP_NAME="$1" APP_URL="$2" ICON_URL="$3" + PROFILE="$4" fi if [[ -z "$APP_NAME" || -z "$APP_URL" || -z "$ICON_URL" ]]; then @@ -16,6 +18,14 @@ if [[ -z "$APP_NAME" || -z "$APP_URL" || -z "$ICON_URL" ]]; then exit 1 fi +if [ "$PROFILE" != "" ]; then + USER_DATA_DIR="$HOME/.cache/ChromiumInstances/$APP_NAME" + mkdir -p "$USER_DATA_DIR" + USER_DATA_DIR="--user-data-dir=${USER_DATA_DIR}" +else + USER_DATA_DIR="" +fi + ICON_DIR="$HOME/.local/share/applications/icons" DESKTOP_FILE="$HOME/.local/share/applications/$APP_NAME.desktop" ICON_PATH="$ICON_DIR/$APP_NAME.png" @@ -32,7 +42,7 @@ cat >"$DESKTOP_FILE" < " --placeholder "Leave it blank for a shared profile, or type "YES" for a separate profile (multiple instances)")' "$HOME/.local/share/omarchy/bin/omarchy-webapp-install" + +sed -i '/ICON_URL="\$3"/ a\ PROFILE="$4"' "$HOME/.local/share/omarchy/bin/omarchy-webapp-install" + +sed -i '/^ICON_DIR=/ i \ +if [ "$PROFILE" != "" ]; then \ + USER_DATA_DIR="$HOME/.cache/ChromiumInstances/$APP_NAME" \ + mkdir -p "$USER_DATA_DIR" \ + USER_DATA_DIR="--user-data-dir=${USER_DATA_DIR}" \ +else \ + USER_DATA_DIR="" \ +fi \ +' "$HOME/.local/share/omarchy/bin/omarchy-webapp-install" + +sed -i 's|^Exec=omarchy-launch-webapp \$APP_URL$|Exec=omarchy-launch-webapp $APP_URL $USER_DATA_DIR|' "$HOME/.local/share/omarchy/bin/omarchy-webapp-install" \ No newline at end of file