Fake Layout - this file not in layouts directory

πŸ‘¨πŸ’» How to add flag wayland for electron applications?

Published on: 2022-07-01

Markdown - πŸ‘¨πŸ’» How to add flag wayland for electron applications?

Hello guys, this post will allow you to use unicode in Electron apps (google-chrome, brave, discord,...) open via rofi

Written by: Krix Daniel

The Astro logo on a dark background with a pink glow.

astro

blogging

Reading time: 2 min read

View count:

Hello guys, this post will allow you to use unicode in Electron apps (google-chrome, brave, discord,…) open via rofi

If you are using i3 (X11) and ibus-bamboo you don’t have to worry about it cause the ibus-bamboo work well in electrons app.

And if you using hyprland (wayland) or any desktrop enviroment based on wayland, and have to use [fcitx] (https://fcitx-im.org/wiki/Fcitx_5) for unicode. Then this post is what you need.

The magic flag

--enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime

Setup with rofi

#!/bin/bash

# List of apps that require the Wayland flags
ELECTRON_APPS=(
  "discord"
  "thunar"
  "code"
  "firefox"
  "google-chrome"
  "brave-browser"
  "obsidian"
  "chromium"
  "vscode"
  "brave"
  # Adding more your application class name
)

# Extract the base command (before any args)
CMD="$1"
BASE_CMD=$(basename "$CMD")
FLAG="--enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime"

# Check if the base command matches any Electron app
for app in "${ELECTRON_APPS[@]}"; do
  if [[ "$BASE_CMD" == "$app" ]]; then
    exec "$CMD" $FLAG
  fi
done

# If not in the list, run as-is with arguments
exec "$@"
$ELECTRON_LAUNCH_SCRIPT=$HOME/.local/bin/rofi-electron-launch 
pkill rofi || rofi -show drun -replace -i -run-command "$ELECTRON_LAUNCH_SCRIPT {cmd}"

Alternative ways

discord --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime

Other ways GPT