Skip to content

Instantly share code, notes, and snippets.

@felipealfonsog
Created September 14, 2025 06:08
Show Gist options
  • Save felipealfonsog/1a2e36c7693050606d8010dae70f8a92 to your computer and use it in GitHub Desktop.
Save felipealfonsog/1a2e36c7693050606d8010dae70f8a92 to your computer and use it in GitHub Desktop.
This Bash script helps launch Google Chrome or Chromium on Arch Linux with KDE, handling known issues with Wayland, KWin, and GPU rendering.
#!/bin/bash
# Script definitivo para lanzar Chrome/Chromium en Arch KDE
# Detecta Wayland y conflictos típicos, fuerza X11 si es necesario
echo "Which browser do you want to run?"
echo "1) Google Chrome"
echo "2) Chromium"
read -rp "Enter 1 or 2: " choice
if [[ "$choice" == "1" ]]; then
BROWSER_CMD="google-chrome-stable"
elif [[ "$choice" == "2" ]]; then
BROWSER_CMD="chromium"
else
echo "Invalid choice. Exiting."
exit 1
fi
# Detectar tipo de sesión
SESSION_TYPE=${XDG_SESSION_TYPE:-x11}
# Función para probar si el bug aparece
check_bug() {
TEMP_LOG=$(mktemp)
# Lanzar navegador de prueba headless y sin GPU
$BROWSER_CMD --headless --disable-gpu --no-sandbox &> "$TEMP_LOG" &
TEST_PID=$!
sleep 5
kill $TEST_PID &> /dev/null
# Buscar errores típicos
if grep -q "GLib: g_main_context_pop_thread_default" "$TEMP_LOG" || \
grep -q "SharedImageManager" "$TEMP_LOG" || \
grep -q "PHONE_REGISTRATION_ERROR" "$TEMP_LOG"; then
rm "$TEMP_LOG"
return 0 # Bug detectado
else
rm "$TEMP_LOG"
return 1 # Sin bug
fi
}
# Lógica principal
if [[ "$SESSION_TYPE" == "wayland" ]]; then
echo "Wayland session detected."
echo "Checking for potential Chrome/Chromium conflicts..."
if check_bug; then
echo "Bug detected! Forcing X11 to avoid errors."
$BROWSER_CMD --ozone-platform=x11 --disable-gpu &
else
echo "No bug detected. Launching $BROWSER_CMD on Wayland."
$BROWSER_CMD &
fi
else
echo "X11 session detected. Launching $BROWSER_CMD normally..."
$BROWSER_CMD &
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment