Have two copies of same app icon after launching it? Here’s step by step tutorial shows how to fix the issue!
Due to bug or incorrect configuration, when launching an application, it may create another copy of app icon on Dock, result in duplicate app icons on your Linux. In the case, this simple tutorial may help to fix the issue.
Option 1: Check if duplicate apps installed, or duplicate shortcut files.
Due to various reasons, there may be multiple versions of same app installed, or multiple app shortcut config files refer to same icon file.
For example, you installed an app via native
.deb/.rpm package, then install the same app through
Snap package. Then, there may be 2 copies of same app visible in your system app launcher (start menu or ‘Activities’ overview search result depends on DE). You pinned one app icon into dock, then launch another one, so there will be duplicate app icons on the dock.
Or, due to mis-configuration, there are multiple app shortcut config files (
.desktop files) created on your system with different rules. One is pinned to dock, but another one is launched.
For example, Rhino Linux 2023.1 have “File Manager“, “File Manager Settings“, “Bulk Rename“, and “Thunar File Manager” in app-grid. All of them have same icon. “File Manager” is pinned to dock, but clicking it will launch “Thunar File Manager” causing 2 app icons on the dock.
In the case, the solution is either uninstall (or hide) the unused copy of the application, or un-pin app icon and re-pin the correct one to the dock. For example, in Rhino Linux 2023.1 just remove the “
File Manager” from the dock, then add “
Thunar File Manager” will fix the duplicate file icon issue.
Option 2: Add “StartupWMClass” config rule
If you have only one copy of that app installed, and there’s only one
.desktop shortcut file with that app icon, then you can try adding the
StartupWMClass tells to group all app windows, with specified class name, to single app shortcut.
Just find out the class name of that opened app window, add
StartupWMClass=the_class_name into the app shortcut’s config file, then the app window will link to that app icon on the dock.
Step 1: Find out class name of the app window
For GNOME, the default desktop environment in Ubuntu, Fedora, and optional in Debian, Arch, etc, it’s easy to find out your windows’ class names via following steps:
- First, press Alt+F2 on keyboard. Then, type lg in pop-up ‘Run a Command’ box. Finally, hit Enter to open GNOME Shell’s integrated debugger and inspector tool.
- Then, in the drop-down dialog, click “Windows” in top-right will list the class name of all the opened windows. In my case, the app is Thunderbird, and, the class name is thunderbird-beta according to the screenshot below.
For non-GNOME desktop environment running on classic Xorg, do the following instead to get the class name:
- First, launch terminal and run the below command:
Once you hit Enter, the mouse cursor should become a ‘crosshair’.
- Then, move the cursor over the destination app window and click on it. The terminal command will done and output the class name of the app window you just clicked.
Step 2: Edit the app shortcut icon’s config file
Each app shortcut has a corresponding config file with
.desktop extension. These
.desktop files are stored in
NOTE: For Flatpak apps, go check
1. Find the file. Open file explorer and go check the 2 directories for the .desktop file for your application. For
.local folder, you need to press Ctrl+H to show/hide hidden file/folders.
2. Open that file. If you found the file in ‘
.local/share/applications‘, just double click to open it with text editor.
If it’s under ‘
/user/share/applications‘, then you need root permission to edit the file. In the case, right-click on blank area in that folder and select “Open in Terminal“.
When terminal opens, run command to edit the file:
sudo gnome-text-editor file_name.desktop
In command, you need to replace the ‘file_name’ accordingly. And, replace
gedit for Ubuntu 22.04 and earlier. If you don’t know which text editor to use, try universal
nano command line text editor instead.
3. Add ‘StartupWMClass=xxx’.
Once the file opened in text editor, add the new line under ‘[Desktop Entry]’ section.
NOTE: You have to replace
thunderbird-beta to the class name that you found in ‘Step 1’.
Finally, save file. For nano text editor, press Ctrl+X, type y and hit Enter.
In short, if you see duplicate app icons on your Linux dock, go check if there are duplicate software packages or shortcut files. Or, add ‘
StartupWMClass=‘ rule to the app shortcut config file should fix the issue.