Created
June 4, 2026 14:25
-
-
Save tiriana/fb66bdd934cc676eea5696a7d96b66b2 to your computer and use it in GitHub Desktop.
Ubuntu script to fix duplicate Steam game shortcuts by appending missing StartupWMClass values
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
| #!/bin/bash | |
| # 1. Copy all Steam shortcuts from Desktop to the system applications folder | |
| cp ~/Desktop/*.desktop ~/.local/share/applications/ 2>/dev/null | |
| # 2. Loop through all application shortcuts to fix them | |
| for file in ~/.local/share/applications/*.desktop; do | |
| # Check if the file is a Steam game launcher and is missing the fix | |
| if grep -q "rungameid" "$file" && ! grep -q "StartupWMClass" "$file"; then | |
| # Extract the numerical AppID from the launch URL | |
| appid=$(grep -oP "rungameid/\K[0-9]+" "$file") | |
| # Append the correct window tracking class line to the end of the file | |
| echo "StartupWMClass=steam_app_$appid" >> "$file" | |
| # Print a clean confirmation message to your terminal screen | |
| echo "Fixed: $(basename "$file") (AppID: $appid)" | |
| fi | |
| done | |
| # 3. Refresh Ubuntu's desktop environment database so the icons update immediately | |
| update-desktop-database ~/.local/share/applications/ |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One liner: