Skip to content

Instantly share code, notes, and snippets.

@pojntfx
Last active March 10, 2024 22:20
Show Gist options
  • Save pojntfx/a06c7a7d45787258701dde4975d067e6 to your computer and use it in GitHub Desktop.
Save pojntfx/a06c7a7d45787258701dde4975d067e6 to your computer and use it in GitHub Desktop.
Enable GTK4, Wayland and hardware acceleration for Chrome on Linux

Update: As of June 2023, Chrome has officially added support for prefers-color-scheme as of this in version 114!

Paste the following into your terminal. You'll have to fully close the browser with pkill chrome each time you want Chrome to re-read the settings.

Also, use the following flags for full GPU acceleration:

  • ignore-gpu-blocklist
  • enable-webrtc-pipewire-capturer
  • enable-gpu-rasterization
  • enable-vulkan
  • enable-zero-copy
  • enable-raw-draw
  • enable-drdc
  • canvas-oop-rasterization

Use https://extensions.gnome.org/extension/2236/night-theme-switcher/ to also toggle the GTK3 & GTK4 theme automatically for apps that don't support switching fully yet.

# For Chrome on Wayland:
echo '/usr/bin/google-chrome-stable --gtk-version=4 --enable-features=UseOzonePlatform --ozone-platform=wayland --use-gl=desktop --enable-features=VaapiVideoDecoder --enable-accelerated-video-decode "$1"' | sudo tee /usr/local/bin/google-chrome-adwaita
sudo chmod +x /usr/local/bin/google-chrome-adwaita
sudo sed -i 's@/usr/bin/google-chrome-stable@/usr/local/bin/google-chrome-adwaita@g' /usr/share/applications/google-chrome.desktop
# For Chrome on X11:
echo '/usr/bin/google-chrome-stable --gtk-version=4 --enable-features=VaapiVideoDecoder --enable-accelerated-video-decode "$1"' | sudo tee /usr/local/bin/google-chrome-adwaita
sudo chmod +x /usr/local/bin/google-chrome-adwaita
sudo sed -i 's@/usr/bin/google-chrome-stable@/usr/local/bin/google-chrome-adwaita@g' /usr/share/applications/google-chrome.desktop
# For Chrome on Nvidia:
echo 'export __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia && /usr/bin/google-chrome-stable --gtk-version=4 "$1"' | sudo tee /usr/local/bin/google-chrome-adwaita
sudo chmod +x /usr/local/bin/google-chrome-adwaita
sudo sed -i 's@/usr/bin/google-chrome-stable@/usr/local/bin/google-chrome-adwaita@g' /usr/share/applications/google-chrome.desktop
@dungsaga
Copy link

This doesn't work in my Ubuntu 20.04 under WSL

@KairuiLiu
Copy link

--gtk-version=4 is currently unavailable on chrome-beta 117

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment