Skip to content

Hardcoded application icons

morganist edited this page Nov 16, 2023 · 4 revisions

The hardcoded application icon is a desktop file (application launcher in Linux) with the full path to the icon in the Icon= attribute that prevents application from using an icon from an installed icon theme such as Papirus.

How to manually fix hardcoded application icons

How to find the path to a desktop file

The .desktop files that you see in a launcher (or a menu) are located in applications directory in $XDG_DATA_DIRS, usually /usr/share/applications.

To find the path in KDE, MATE, Xfce, and Budgie, find the app in the applications menu and simply drag and drop its icon to a terminal window.

Unfortunately, this method doesn't work in GNOME Shell and Cinnamon. To find the path to a desktop file in these Desktop Environments, you can use an app name that you can see in the dash or the application launcher.

For example, let's find the path to the Boot Repair desktop file:

grep -irl "Boot Repair" /usr/share/applications
# ^   ^    ^            ^
# |   |    |            |- a directory that ussually contains desktop files
# |   |    |- application name that you see in the application menu
# |   |- short form of --ignore-case --recursive --files-with-matches
# |- a program that searches for PATTERNS in files
#
# Output:
/usr/share/applications/boot-repair.desktop  # <-- here is the path that we're looking for

Sometime, you can't found a desktop file in /usr/share/applications, in this case I recommend to search in each directory listed in $XDG_DATA_DIRS. Use the following snippet to do it:

# bash
grep -irl "App Name" ${XDG_DATA_DIRS//://applications }/applications

# zsh
for d (${(s/:/)XDG_DATA_DIRS}); grep -irl "App Name" $d/applications

How to fix a hardcoded application icon

To fix a hardcoded application icon, we will use the desktop-file-install command, which is a part of the desktop-file-utils package, so make sure you have installed it in case if the command is missing. Of course, we can use desktop-file-edit instead, but we will copy a desktop file to $HOME/.local/share/applications/ to avoid overriding our changes after an app update.

The second important thing we need is the name of app icon in Papirus icon theme. You can use the search box in File Finder, find, or fd commands locally. You can also just search a folder using your file manager or use KDE Plasma's icon chooser dialog (invoked when editing a .desktop file with Menu Editor and clicking on an icon).

NOTE:

Use the file name only, without the path and without the file extension:

/usr/share/icons/Papirus/48x48/apps/barrier.svgbarrier

When we have found the icon name and the path, we can build our command to use the following template:

desktop-file-install --set-icon=ICON_NAME --dir ~/.local/share/applications PATH_TO_DESKTOP_FILE

For example, this is how I have fixed the application icon for Barrier app:

grep -rl 'Barrier' /usr/share/applications
# Output:
# /usr/share/applications/barrier.desktop <-- this is a file we need
# /usr/share/applications/gnome-universal-access-panel.desktop
find /usr/share/icons/Papirus/ -iname '*Barrier*' -printf '%f\n'
# Output:
# barrier.svg <-- let's use this icon, but without a file extension
# com.github.debauchee.barrier.svg
# ...
desktop-file-install --set-icon=barrier --dir ~/.local/share/applications /usr/share/applications/barrier.desktop