Fix browser detection and remove standalone configuration script
- Rewrite browser detection to check config directories instead of commands - Fix Brave browser detection and configuration (was not being reported) - Add proper support for Chromium installed via snap - Separate detection for each browser (Firefox, Brave, Chrome, Chromium) - Each browser now reports configuration success individually - Remove standalone configure-apps-for-tmpfs.sh script per user request - Keep all functionality in the all-in-one optimizer script - Update README to remove reference to standalone script Fixes: - Brave browser now properly detected via ~/.config/BraveSoftware - Chromium detected even when installed as snap package - All browsers report their configuration status - Cleaner, more reliable directory-based detection
This commit is contained in:
@@ -895,60 +895,12 @@ configure_applications_for_tmpfs() {
|
||||
fi
|
||||
done
|
||||
|
||||
# Chrome/Chromium
|
||||
if command -v google-chrome &>/dev/null || command -v chromium &>/dev/null; then
|
||||
local chrome_dir="$user_home/.config/google-chrome"
|
||||
local chromium_dir="$user_home/.config/chromium"
|
||||
|
||||
for browser_dir in "$chrome_dir" "$chromium_dir"; do
|
||||
if [[ -d "$browser_dir" ]]; then
|
||||
local browser_name=$(basename "$browser_dir")
|
||||
mkdir -p /tmp/tmpfs-cache/browser/$browser_name
|
||||
|
||||
# Create wrapper script to launch with cache dir
|
||||
local desktop_file=""
|
||||
if [[ "$browser_name" == "google-chrome" ]]; then
|
||||
desktop_file="$user_home/.local/share/applications/google-chrome.desktop"
|
||||
cat > "$desktop_file" << 'CHROMEOF'
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Name=Google Chrome (tmpfs optimized)
|
||||
Exec=google-chrome --disk-cache-dir=/tmp/tmpfs-cache/browser/google-chrome %U
|
||||
StartupNotify=true
|
||||
Terminal=false
|
||||
Icon=google-chrome
|
||||
Type=Application
|
||||
Categories=Network;WebBrowser;
|
||||
MimeType=text/html;text/xml;application/xhtml+xml;x-scheme-handler/http;x-scheme-handler/https;
|
||||
CHROMEOF
|
||||
else
|
||||
desktop_file="$user_home/.local/share/applications/chromium.desktop"
|
||||
cat > "$desktop_file" << 'CHROMIUMEOF'
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Name=Chromium (tmpfs optimized)
|
||||
Exec=chromium --disk-cache-dir=/tmp/tmpfs-cache/browser/chromium %U
|
||||
StartupNotify=true
|
||||
Terminal=false
|
||||
Icon=chromium
|
||||
Type=Application
|
||||
Categories=Network;WebBrowser;
|
||||
MimeType=text/html;text/xml;application/xhtml+xml;x-scheme-handler/http;x-scheme-handler/https;
|
||||
CHROMIUMEOF
|
||||
fi
|
||||
|
||||
chown $current_user:$current_user "$desktop_file" 2>/dev/null || true
|
||||
chmod +x "$desktop_file" 2>/dev/null || true
|
||||
|
||||
success " ✅ $browser_name configured to use tmpfs cache"
|
||||
((configured_count++))
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Brave
|
||||
# Brave Browser
|
||||
if [[ -d "$user_home/.config/BraveSoftware" ]]; then
|
||||
mkdir -p /tmp/tmpfs-cache/browser/brave
|
||||
mkdir -p "$user_home/.local/share/applications"
|
||||
chown -R $current_user:$current_user /tmp/tmpfs-cache/browser/brave
|
||||
|
||||
local brave_desktop="$user_home/.local/share/applications/brave-browser.desktop"
|
||||
cat > "$brave_desktop" << 'BRAVEEOF'
|
||||
[Desktop Entry]
|
||||
@@ -964,7 +916,57 @@ MimeType=text/html;text/xml;application/xhtml+xml;x-scheme-handler/http;x-scheme
|
||||
BRAVEEOF
|
||||
chown $current_user:$current_user "$brave_desktop" 2>/dev/null || true
|
||||
chmod +x "$brave_desktop" 2>/dev/null || true
|
||||
success " ✅ Brave configured to use tmpfs cache"
|
||||
success " ✅ Brave Browser configured to use tmpfs cache"
|
||||
((configured_count++))
|
||||
fi
|
||||
|
||||
# Google Chrome
|
||||
if [[ -d "$user_home/.config/google-chrome" ]]; then
|
||||
mkdir -p /tmp/tmpfs-cache/browser/google-chrome
|
||||
mkdir -p "$user_home/.local/share/applications"
|
||||
chown -R $current_user:$current_user /tmp/tmpfs-cache/browser/google-chrome
|
||||
|
||||
local chrome_desktop="$user_home/.local/share/applications/google-chrome.desktop"
|
||||
cat > "$chrome_desktop" << 'CHROMEOF'
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Name=Google Chrome (tmpfs optimized)
|
||||
Exec=google-chrome --disk-cache-dir=/tmp/tmpfs-cache/browser/google-chrome %U
|
||||
StartupNotify=true
|
||||
Terminal=false
|
||||
Icon=google-chrome
|
||||
Type=Application
|
||||
Categories=Network;WebBrowser;
|
||||
MimeType=text/html;text/xml;application/xhtml+xml;x-scheme-handler/http;x-scheme-handler/https;
|
||||
CHROMEOF
|
||||
chown $current_user:$current_user "$chrome_desktop" 2>/dev/null || true
|
||||
chmod +x "$chrome_desktop" 2>/dev/null || true
|
||||
success " ✅ Google Chrome configured to use tmpfs cache"
|
||||
((configured_count++))
|
||||
fi
|
||||
|
||||
# Chromium
|
||||
if [[ -d "$user_home/.config/chromium" ]]; then
|
||||
mkdir -p /tmp/tmpfs-cache/browser/chromium
|
||||
mkdir -p "$user_home/.local/share/applications"
|
||||
chown -R $current_user:$current_user /tmp/tmpfs-cache/browser/chromium
|
||||
|
||||
local chromium_desktop="$user_home/.local/share/applications/chromium-browser.desktop"
|
||||
cat > "$chromium_desktop" << 'CHROMIUMEOF'
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Name=Chromium (tmpfs optimized)
|
||||
Exec=chromium --disk-cache-dir=/tmp/tmpfs-cache/browser/chromium %U
|
||||
StartupNotify=true
|
||||
Terminal=false
|
||||
Icon=chromium
|
||||
Type=Application
|
||||
Categories=Network;WebBrowser;
|
||||
MimeType=text/html;text/xml;application/xhtml+xml;x-scheme-handler/http;x-scheme-handler/https;
|
||||
CHROMIUMEOF
|
||||
chown $current_user:$current_user "$chromium_desktop" 2>/dev/null || true
|
||||
chmod +x "$chromium_desktop" 2>/dev/null || true
|
||||
success " ✅ Chromium configured to use tmpfs cache"
|
||||
((configured_count++))
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user