protonscr

StartupWMClass in .desktop file

steamopen Feature Request
ValveSoftware/steam-for-linux#7034 · opened 2020-04-16 by 8Kuula · updated 2026-07-18 · 18 comments · github
88Kuula 2020-04-16 github

Your system information

  • Steam client version (build number or date): Apr 4 2020, at 00:37:27
  • Distribution (e.g. Ubuntu): Ubuntu 18.04
  • Opted into Steam client beta?: No
  • Have you checked for system updates?: Yes

Please describe your issue in as much detail as possible:

Add StartupWMClass variable in .desktop file when shortcut to desktop is created.

I move .desktop file to '~/.local/share/applications' so I can have it on launcher.
Now, when launching a game, launcher creates extra icon. Instead of using already one in there.

Attempted this with Stellaris game. I Added manually it to Stellaris.desktop file;
StartupWMClass=stellaris

Kkbroulik 2020-05-30 github

Actually, Steam appears to write some extra properties onto windows. I've noticed a STEAM_GAME property on the window of Steam games, matching the Game ID in the library, for instance, calling xprop on a Counter-Strike: Source window gives me:

STEAM_GAME(CARDINAL) = 240

This luckily isn't unique to Valve games, I've noticed it does that for third party games, too.

I think StartupWMClass won't be sufficient as for instance all games based on Half-Life 2 games, such as Counter-Strike: Source have a WM_CLASS of hl2_linux. What I think Steam should be doing instead, is write the actual desktop file name of the game onto its window.

I thought there was a cross-desktop property for this nowadays but that might have only been for Wayland. I only find a KDE-specific _KDE_NET_WM_DESKTOP_FILE or _GTK_APPLICATION_ID. In any case, when I manually write the corresponding desktop file onto the window, it is properly identified and can be pinned to the task bar:

xprop -id 0x5e00014 -f _KDE_NET_WM_DESKTOP_FILE 8u -set "_KDE_NET_WM_DESKTOP_FILE" "Counter-Strike Source.desktop"

(With 0x5e00014 being the window id of the window, as determined by e.g. xwininfo)

The given desktop file must exist for it to work, obviously.

I made a proof of concept helper application that automatically reads the STEAM_GAME property and finds the corresponding desktop file: https://github.com/kbroulik/steam-x-proper

Eernstp 2022-02-16 github

I ran
xprop WM_CLASS
on Path of Exile
WM_CLASS(STRING) = "steam_app_238960", "steam_app_238960"
Then adding
StartupWMClass=steam_app_238960
to my ".local/share/applications/Path of Exile.desktop"
correctly groups the game window with the launcher icon i Ubuntu Wayland session.

So this would be perfect to add to Proton games!

Sscallaway 2024-05-14 github

I believe this to still be an issue in 2024.

I've been trying to work out for months why I wasn't able to see the icon of the currently running game in the dock that I'm using (GNOME 46).

Turns out it's due to the fact that Steam doesn't include this required property in the Desktop files. Like others have said, manually adding it myself sorted the issue (although I'll have to go through and do this for all applications manually).

If this could be automatically included, that would be great.

00011FF 2024-07-19 github

I created a simple bash script that adds "StartupWMClass=steam_app_{steam_id}" to .desktop files of steam apps in the current directory:

#!/bin/bash
changed_files=()
for filename in ./*.desktop; do
    printf "\n\n$filename\n"
    steam_icon_line=$(cat "$filename" | grep "Icon=steam_icon")
    
    if [[ -z "$steam_icon_line" ]]
    then
        printf "not a steam shortcut, skipping..."
        continue
    fi
    
    IFS='_'
    read -ra steam_icon_array <<< "$steam_icon_line"
    steam_id=${steam_icon_array[2]}
    
    new_wmclass_line=$(printf "StartupWMClass=steam_app_${steam_id}")
    
    if [[ ! -z $(cat "$filename" | grep "$new_wmclass_line") ]]
    then
        printf "already has StartupWMClass, no changes needed..."
        continue
    fi
    
    printf "adding \"$new_wmclass_line\" to end of file..."
    printf "\n$new_wmclass_line" >> $filename
    changed_files+=("$filename")
done

printf "\n\n\nAdded StartupWMClass to files:\n"
printf "%s\n" "${changed_files[@]}"

I have very little experience in bash so it might be a little sloppy but it seems to work fine (you might want to make a backup to test)

This won't solve the issue for all games unfortunately, as I have noticed that some steam games use the name of the binary file as the wmclass rather than the app id. Valheim uses "valheim.x86_64" and Vampire Survivors uses "VampireSurvivors.exe"

AAlofBronco 2024-12-16 github

Valve still haven't fixed it
Good that i found this answer

Xx5f3759df 2025-01-22 github

It will be nice to have, I guess

Zzquestz 2025-06-14 github

Any chance you can just consistently put "steam_app_123456", where 123456 is the unique game number on Steam as one of the active WM_Class strings? Or just be smart enough to set StartupWMCLass to a valid value when creating the .desktop file?

This would give everyone on Linux nice icons when they launch their games, and resolve this 5 year old issue.

Xx5f3759df 2025-06-14 github

KDE doesn't have this problem. I think they don't really fix it because it is more like GNOME problem.

Zzquestz 2025-06-15 github

It affects at least GNOME, Cinnamon, Xfce and MATE if not others.

PPeppoDev 2025-07-16 github

Guys I made a script for this to fix it on gnome app menu automatically. I dont have much knowledge about others DEs, but it could be extended to other use cases.
Also, if someone have a idea to cover non proton games would be great (it changes a lot depending on the game)

Check this out

PPeppoDev 2025-07-16 github

I was thinking on the worst case, map all StartupWMClass for native games and hardcode it, maybe

PPeppoDev 2025-07-16 github

I maped some that I have, but its harder if you consider that someone could have this games running natively or with proton (in some cases are just better run on proton)

Dead cells - deadcells
Counter strike 2 - cs2
Hollow Knight - hollow_knight.x86_64
Broforce - Broforce.x86_64
Left 4 Dead - hl2_linux

Xx5f3759df 2025-07-20 github

It affects at least GNOME, Cinnamon, Xfce and MATE if not others.

I don't know how it really works, but it is not issue on KDE - everything shows using they icons (even when I launch something with wine or proton)

I can relate this with GTK maybe?

Kkbroulik 2025-07-20 github

It's not just about the icon. It also breaks pinning the game to task bar among other things.

Jjohnlogostini 2026-07-17 github

Just wanted to bump this issue back up. This is not an issue on KDE, either on Wayland or X11, but on GNOME, on both Wayland and X11, this is a problem.

Basically, each individual window has its name derived from the application. However, in the main app bar it just shows as steam_app_{ID} and both lack an icon.

The fix is literally just adding a StartupWMClass entry in the .desktop file created when installing a game through Steam. This can go anywhere; .desktop files are read regardless. I personally use:

/home/{USERNAME}/.local/share/applications/{GAME}.desktop

These screenshots show the before and after. It makes this feel much more official and polished. I am unaware of any side effects, but I'll post an update if I find any.

I'd suggest Steam automatically add this StartupWMClass entry when creating the desktop file to improve the user experience.

Disney Infinity 3.0 Gold Edition.desktop

[Desktop Entry]
Name=Disney Infinity 3.0: Gold Edition
Comment=Play this game on Steam
Exec=steam steam://rungameid/541670
Icon=steam_icon_541670
Terminal=false
Type=Application
Categories=Game;
StartupWMClass=steam_app_541670

Before

Image

After

Image
PPeppoDev 2026-07-17 github

For those on this thread, I created a extension to fix this problem.

Extension
REPO

Jjohnlogostini 2026-07-18 github

For those on this thread, I created a extension to fix this problem.

Extension REPO

That's actually really interesting. I'll take a look. I hate that I manually have to manage my system bar icons it feels useless, especially when you have things like Blender, where if you set the StartupWMClass based on the executable name, it bundles multiple Blender versions together.

I need to learn more about how and why StartupWMClass works, and I'll definitely take a look at your extension. Thanks!

PPeppoDev 2026-07-18 github

@johnlogostini

I explained a little about the problem and why it works o Gnome on this thread.

Nothing extracted yet.