From 618ea7d12d8a3246e8d9c364ab6c8c0185768368 Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 19 Feb 2026 17:33:26 +1300 Subject: [PATCH] Prefer usr/user-data for portable data Rename and consolidate portable user-data to usr/user-data and update tooling and runtime to match. Updated appdir-example/run-nebula.sh to point at usr/user-data; make-appdir.sh and update-appdir.sh now patch/copy the launcher, create the usr/user-data directory and set secure permissions (mkdir -p, chmod 700), and remove sed backups. portable-data.js now defaults to app-local user-data and prefers /usr/user-data on Linux AppDir builds (with safe fs checks). Also minor UI change in renderer/setup.css to make the footer background transparent and disable the backdrop blur. --- appdir-example/run-nebula.sh | 4 ++-- make-appdir.sh | 3 +++ portable-data.js | 32 ++++++++++++++++++-------------- renderer/setup.css | 4 ++-- update-appdir.sh | 11 +++++++++++ 5 files changed, 36 insertions(+), 18 deletions(-) diff --git a/appdir-example/run-nebula.sh b/appdir-example/run-nebula.sh index 82568df..f80df49 100755 --- a/appdir-example/run-nebula.sh +++ b/appdir-example/run-nebula.sh @@ -1,6 +1,6 @@ #!/bin/bash # Run Nebula with portable data storage -# User data (cookies, history, bookmarks) is stored in usr/data/ alongside the app. +# User data (cookies, history, bookmarks) is stored in usr/user-data/ alongside the app. set -e HERE="$(cd "$(dirname "$0")" && pwd)" @@ -11,7 +11,7 @@ export LD_LIBRARY_PATH="$HERE/usr/lib:$HERE/usr/lib64:$LD_LIBRARY_PATH" # --- PORTABLE DATA CONFIGURATION --- # Store user data in a local folder for portable operation -PORTABLE_DATA_DIR="$HERE/usr/data" +PORTABLE_DATA_DIR="$HERE/usr/user-data" export NEBULA_PORTABLE=1 export NEBULA_PORTABLE_PATH="$PORTABLE_DATA_DIR" diff --git a/make-appdir.sh b/make-appdir.sh index 80fdf73..582d348 100755 --- a/make-appdir.sh +++ b/make-appdir.sh @@ -67,6 +67,7 @@ fi # Copy Linux launch wrappers if present in appdir-example if [ -f "$SCRIPT_DIR/appdir-example/run-nebula.sh" ]; then cp "$SCRIPT_DIR/appdir-example/run-nebula.sh" "$DEST/run-nebula.sh" + sed -i.bak 's|usr/data|usr/user-data|g' "$DEST/run-nebula.sh" && rm -f "$DEST/run-nebula.sh.bak" chmod +x "$DEST/run-nebula.sh" || true fi if [ -f "$SCRIPT_DIR/appdir-example/steam_appid.txt" ]; then @@ -93,6 +94,8 @@ fi # Fix permissions chmod -R a+r "$DEST/usr/share/icons/hicolor/256x256/apps" || true chmod +x "$DEST/Nebula" "$DEST/Nebula-Desktop" "$DEST/Nebula-Controller" || true +mkdir -p "$DEST/usr/user-data" +chmod 700 "$DEST/usr/user-data" || true echo "AppDir assembled at $DEST." echo " Desktop mode: $DEST/Nebula-Desktop" diff --git a/portable-data.js b/portable-data.js index fe2e967..057dc77 100644 --- a/portable-data.js +++ b/portable-data.js @@ -85,8 +85,8 @@ class PortableDataManager { /** * Get the portable data directory path - * Uses NEBULA_PORTABLE_PATH if set, otherwise creates 'user-data' in Documents/My Games/ - * with a safe fallback to the app directory. + * Uses NEBULA_PORTABLE_PATH if set, otherwise creates app-local 'user-data'. + * Linux AppDir builds prefer 'usr/user-data' to keep writable data inside AppDir. */ getPortableDataPath() { if (this._portableDataPath !== null) { @@ -111,19 +111,23 @@ class PortableDataManager { } } - // Default: prefer Documents/My Games//user-data - let dataPath = ''; - try { - const docsDir = app.getPath('documents'); - const appName = app.getName() || 'NebulaBrowser'; - dataPath = path.join(docsDir, 'My Games', appName, 'user-data'); - } catch (err) { - console.warn('[Portable] Failed to resolve Documents path, using app directory'); - } + // Default: app-local user data + // - Windows: beside the executable + // - macOS: inside .app Contents (portable bundle) + // - Linux AppDir: /usr/user-data + // - Other Linux/dev: beside the app root + const appRoot = this._getAppRootDir(); + let dataPath = path.join(appRoot, 'user-data'); - if (!dataPath) { - const appRoot = this._getAppRootDir(); - dataPath = path.join(appRoot, 'user-data'); + if (process.platform === 'linux') { + const appDirUsr = path.join(appRoot, 'usr'); + try { + if (fs.existsSync(appDirUsr) && fs.statSync(appDirUsr).isDirectory()) { + dataPath = path.join(appDirUsr, 'user-data'); + } + } catch (err) { + console.warn('[Portable] Could not inspect Linux AppDir usr path, using app root user-data'); + } } // Validate the path diff --git a/renderer/setup.css b/renderer/setup.css index 1cc8323..7d424e8 100644 --- a/renderer/setup.css +++ b/renderer/setup.css @@ -531,8 +531,8 @@ body, html { padding-bottom: 1rem; position: sticky; bottom: 0; - background: linear-gradient(180deg, rgba(18, 20, 24, 0), rgba(18, 20, 24, 0.85) 45%, rgba(18, 20, 24, 0.95)); - backdrop-filter: blur(6px); + background: transparent; + backdrop-filter: none; } .btn { diff --git a/update-appdir.sh b/update-appdir.sh index c5a1ef8..9c81d36 100755 --- a/update-appdir.sh +++ b/update-appdir.sh @@ -84,6 +84,12 @@ done # Update main launcher scripts if present echo "" echo "🔄 Syncing launcher scripts..." +if [ -f "$SCRIPT_DIR/appdir-example/run-nebula.sh" ]; then + cp "$SCRIPT_DIR/appdir-example/run-nebula.sh" "$APPDIR_ROOT/run-nebula.sh" + sed -i.bak 's|usr/data|usr/user-data|g' "$APPDIR_ROOT/run-nebula.sh" && rm -f "$APPDIR_ROOT/run-nebula.sh.bak" + chmod +x "$APPDIR_ROOT/run-nebula.sh" || true + echo " ✓ run-nebula.sh" +fi for launcher in "Nebula-Desktop" "Nebula-Controller"; do if [ -f "$SCRIPT_DIR/nebula-appdir/$launcher" ]; then cp "$SCRIPT_DIR/nebula-appdir/$launcher" "$APPDIR_ROOT/$launcher" @@ -116,6 +122,11 @@ for dir in "${DIRS[@]}"; do fi done +# Ensure portable user-data directory exists for Linux AppDir builds +mkdir -p "$APPDIR_ROOT/usr/user-data" +chmod 700 "$APPDIR_ROOT/usr/user-data" || true +echo " ✓ usr/user-data/" + echo "" echo "✅ AppDir updated successfully!" echo ""