Fix Duplicate App Icons on Dock Launcher in Ubuntu, Fedora

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 Flatpak or 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.

Rhino Linux has multiple ‘file’ icons

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 rule.

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:

  1. 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.
  2. 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:

  1. First, launch terminal and run the below command:
    xprop WM_CLASS

    Once you hit Enter, the mouse cursor should become a ‘crosshair’.

  2. 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

  • either /usr/share/applications
  • or .loca/share/applications directories.
NOTE: For Flatpak apps, go check /var/lib/flatpak/exports/share/applications/ directory.

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 gnome-text-editor with 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.

  • StartupWMClass=thunderbird-beta

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.

Summary

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.

Hi, I'm Merilyn Ne, a computer geek working on Ubuntu Linux for many years and would like to write useful tips for beginners. Forgive me for language mistakes. I'm not a native speaker of English.