Last active
October 8, 2025 16:57
-
-
Save felipealfonsog/f54bad5dfc6e2254b6d7974aabdeb1b7 to your computer and use it in GitHub Desktop.
Fix for Brave & Chrome work in XWayland / Wayland
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Enable native Wayland support for Chromium-based browsers | |
| # Tested on Arch Linux | |
| set -e | |
| FLAGS=( | |
| "--enable-features=UseOzonePlatform" | |
| "--ozone-platform=wayland" | |
| "--enable-features=WebRTCPipeWireCapturer" | |
| "--enable-features=WaylandWindowDecorations" | |
| "--disable-features=WaylandFractionalScaleV1" | |
| ) | |
| CONFIG_DIR="$HOME/.config" | |
| apply_flags() { | |
| local browser=$1 | |
| local file="$CONFIG_DIR/${browser}-flags.conf" | |
| if [[ -f "$file" ]]; then | |
| echo "Backing up existing $file to ${file}.bak" | |
| mv "$file" "${file}.bak" | |
| fi | |
| echo "Applying Wayland flags to $file" | |
| for flag in "${FLAGS[@]}"; do | |
| echo "$flag" >> "$file" | |
| done | |
| } | |
| for browser in brave chrome chromium; do | |
| apply_flags "$browser" | |
| done | |
| echo "✅ Done! Restart your session and launch Brave/Chrome/Chromium to use Wayland natively." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Enable native Wayland support for Chromium-based browsers on Kali Linux | |
| # Automatically edits .desktop files and reloads KDE menus | |
| set -e | |
| FLAGS="--enable-features=UseOzonePlatform --ozone-platform=wayland --enable-features=WebRTCPipeWireCapturer --enable-features=WaylandWindowDecorations --disable-features=WaylandFractionalScaleV1" | |
| echo "=== Detecting browsers installed on the system ===" | |
| BROWSERS=( | |
| "chromium" | |
| "chromium-browser" | |
| "google-chrome-stable" | |
| "brave-browser" | |
| ) | |
| for browser in "${BROWSERS[@]}"; do | |
| if command -v "$browser" >/dev/null 2>&1; then | |
| echo "Found $browser" | |
| # Find its desktop file | |
| DESKTOP_FILE=$(grep -rl "Exec=.*$browser" /usr/share/applications 2>/dev/null || true) | |
| if [[ -z "$DESKTOP_FILE" ]]; then | |
| DESKTOP_FILE="$HOME/.local/share/applications/${browser}.desktop" | |
| mkdir -p "$(dirname "$DESKTOP_FILE")" | |
| echo "Creating new .desktop file for $browser at $DESKTOP_FILE" | |
| cat >"$DESKTOP_FILE" <<EOF | |
| [Desktop Entry] | |
| Name=$browser | |
| Comment=Web Browser | |
| Exec=$browser %U | |
| Terminal=false | |
| Type=Application | |
| Categories=Network;WebBrowser; | |
| StartupNotify=true | |
| EOF | |
| fi | |
| echo "Backing up existing .desktop file to ${DESKTOP_FILE}.bak" | |
| cp "$DESKTOP_FILE" "${DESKTOP_FILE}.bak" | |
| echo "Modifying Exec line to include Wayland flags" | |
| sudo sed -i "s|^Exec=.*|Exec=$browser $FLAGS %U|" "$DESKTOP_FILE" | |
| echo "✅ $browser updated with Wayland flags" | |
| fi | |
| done | |
| echo "=== Rebuilding KDE menus and icon cache ===" | |
| kbuildsycoca5 --noincremental | |
| kbuildsycoca6 --noincremental | |
| kquitapp5 plasmashell && kstart5 plasmashell & | |
| echo "✅ Done! Launch your browsers to use Wayland natively." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment