Skip to content

Hardcoded application icons

Sergei Eremenko edited this page Oct 11, 2023 · 4 revisions

The hardcoded application icon is a desktop file (application launcher in Linux) with the full path to the icon in Icon= key that denied using any other icon.

How to manually fix hardcoded application icons

How to find the path to a desktop file

The .desktop files what 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 you could find the app in the applications menu and simply drag and drop its icon to the 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 could use an app name what you can see in the application launcher.

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

grep -irl "Boot Repair" /usr/share/applications
# ^   ^    ^            ^
# |   |    |            |- a directory that ussually contains desktop files
# |   |    |- application name what you see in the application menu
# |   |- short form for --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 what we lookong 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 hardcoded application icon

To fix hardcoded application icon, we will use desktop-file-install command, which part of desktop-file-utils package, make sure you have installed it if the command is missing. Of course, we can use desktop-file-edit instead, but we'll 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 on File Finder, find, or fd commands locally.

NOTE:

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

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

When we 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, I have fixed application icon for Barrier app:

grep -rl 'Barrier' /usr/share/applications
# Output:
# /usr/share/applications/barrier.desktop <-- this file we needed
# /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, without file extension
# com.github.debauchee.barrier.svg
# ...
desktop-file-install --set-icon=barrier --dir ~/.local/share/applications /usr/share/applications/barrier.desktop
Clone this wiki locally