Fixing Web Apps (Microsoft Edge) use Wayland Icons in KDE Plasma

Update: Fixing the file name fixes both the taskbar icon and task switcher icon.

After a recent bout of updates on my Kubuntu desktop, I noticed that msedge web apps always show the Wayland Icon for the running window. This is pretty annoying – turns out the problem is a mismatch of StartupWMClass in the application files – the better fix is renaming the file to match the StartupWMClass instead.

msedge will store the application files under ${HOME}/.local/share/applications. The files will be msedge-*.desktop. You can update the StartupWMClass manually by finding out what the right value is – to do this, you run the web app, open KDE > Settings > Search > Window Rules > + Add New > Detect Window Properties and click on the web app window. This should show you all relevant properties of the window including Window Class which is what we want to set as StartupWMClass value in the msedge-*.desktop file.

From my investigation, it looks like the StartupWMClass for msedge applications as of this writing is simply msedge-_<rest of filename>. So here’s a simple script that should fix all your msedge-*.desktop files so they have the right icons in the task bar and switcher, get grouped correctly when running under KDE Plasma:

#!/bin/bash

app_dir="${HOME}/.local/share/applications"
app_backup_dir="${HOME}/msedge-apps"

if [ ! -d "${app_backup_dir}" ]; then
  echo "Creating ${app_backup_dir}"
  mkdir -p "${app_backup_dir}"
fi

for file in "$app_dir"/msedge-*; do
  filename=$(basename "$file")

  if [[ "$filename" == msedge-_* ]]; then
    echo "Skipping already fixed file: $filename"
    continue
  fi

  echo "Fixing ${filename}"
  cp "${file}" "${app_backup_dir}/"
  rest="${filename#msedge-}"
  rest="${rest%%.*}"
  new_filename="msedge-_${rest}.desktop"
  mv "${file}" "$app_dir/${new_filename}"
done

You can see the script here as well – https://github.com/ram-nat/scripts/blob/main/fix_msedge_icons.sh

1 Reply to “Fixing Web Apps (Microsoft Edge) use Wayland Icons in KDE Plasma”

  1. Hey, could you tell me if the script will work on gnome? If not, could you tell me what to edit for Gnome. I would be immensely grateful.

Leave a Reply

Your email address will not be published. Required fields are marked *