1. Overview

In this tutorial, we’ll learn how to change the icons for GTK-based applications. We’ll begin by picking and installing icons. Next, we’ll use a couple of GUI utilities to change the icon for GTK applications.

Then, we’ll discuss how to set GTK themes manually through configuration files. Finally, we’ll see how to set the icon for the GNOME desktop and install custom emblems.

2. Icon Installation

By default, GTK applications use the Adwaita icon theme. If we wish to change it, we can install the icon theme of our liking.

2.1. Finding Icons

There are several sources where we can find and download icons:

In addition, some of the popular icon packs are available on the official package repositories. For instance, on Ubuntu, we search for “icon-theme” using apt:

$ sudo apt search icon-theme | grep -i /lunar
adwaita-icon-theme/lunar,now 41.0-1ubuntu1 all [installed,automatic]
breathe-icon-theme/lunar 0.51.2 all
breeze-icon-theme/lunar 4:5.104.0-0ubuntu1 all
budgie-desktop-environment/lunar-updates 0.19.4~23.04.1 all
deepin-icon-theme/lunar 2021.11.24-1 all
elementary-icon-theme/lunar 7.2.0-1 all
...

2.2. Installing Icons

For the icon pack in the repository, we use a package manager:

$ sudo apt install -y numix-icon-theme-circle

However, if the icon pack isn’t available in the repository, then we simply download the pack from the mentioned sources. Often, the icon pack includes an installation script.

However, if there is no installation script, we install the icon pack by copying the icons directory to /usr/share/icons:

$ sudo cp -r ~/Downloads/icon-dir/ /usr/share/icons

Alternatively, we can install the icons for the current user to ~/.local/share/icons:

$ cp -r ~/Downloads/icon-dir/ ~/.local/share/icons

Let’s not forget to update the icon cache:

$ sudo gtk-update-icon-cache -f -t /usr/share/icons
gtk-update-icon-cache: Cache file created successfully.

Updating the icon cache improves performance. Besides, it also ensures that changes to the icon theme take effect in applications.

3. GNOME Tweaks

GNOME is very opinionated in terms of how it looks and behaves. So, there’s no way in the settings to customize the look and feel of it. For that purpose, we use GNOME Tweaks.

GNOME Tweaks allows us to configure how GNOME and GTK applications look. It’s available in the official package repository under its canonical name, gnome-tweaks:

$ sudo apt install -y gnome-tweak-tool

Once installed, we launch it from the application menu or via CLI:

$ gnome-tweaks

Next, we select “Appearance” from the sidebar:

GNOME Tweaks

Now, we select the theme from the “Icons” drop-down, which is “Numix-Circle” in this case:

Tweaks: Select Icon

Afterward, GNOME Tweaks effectively applies the settings:

Numix Icon Theme

Notably, the theme applies to both GTK 2, GTK 3, and GTK 4 applications:

Geany and Nautilus

Geany, in the background, uses GTK 2, while Nautilus uses GTK 4.

4. LXAppearance

LXAppearance is a lightweight utility to change the look and feel of LXDE (Lightweight X11 Desktop Environment). However, it also works for changing the icons of GTK applications.

We install it from the official package repository using its canonical name, lxappearance:

$ sudo apt install -y lxappearance

Next, we launch it from the application menu or via CLI:

$ lxappearance

Now, we head over to the “Icon Theme” tab and select the icon theme from the list:

LXAppearance

Once the icon theme is selected, we click “Apply” for the changes to take effect.

Now, the question is, why use LXAppearance if we have GNOME Tweaks? Well, aptly, GNOME Tweaks is very specific to GNOME. So, if we’re using a tiling window managers like i3, then GNOME Tweaks pulls a lot of GNOME-specific dependencies during installation. On the other hand, LXAppearance requires little dependencies and works just as well.

5. GTK Configuration Files

Alternatively, if GUI sounds too fancy to change the icon theme, then we can tinker with the GTK config files to achieve the same result. This way, it gives us more control because we can change the icon theme for GTK 2, GTK 3, and GTK 4 separately.

Additionally, we can automate this process much more easily. For instance, we can streamline this by backing up the dotfiles and applying them across multiple Linux machines.

5.1. GTK 2

The config file for GTK 2 resides in ~/.gtkrc-2.0. If it doesn’t exist, then we can create one:

$ touch ~/.gtkrc-2.0

In the file, we’ll add the line for the icon theme:

gtk-icon-theme-name="Numix-Circle"
...

Now, we need to restart the session for the change to take effect.

One thing we should keep in mind is that this file will be overwritten by tools like LXAppearance. In order to avoid that, we’ll need to create a new file and import that file into ~/.gtkrc-2.0:

$ echo "gtk-icon-theme-name=\"Numix-Circle\"" >> ~/.gtkrc-2.0.mine && \
echo 'include "/home/baeldung/.gtkrc-2.0.mine"' >> ~/.gtkrc-2.0

Here, we add the line for setting the icon theme in the ~/gtkrc-2.0.mine file and include that file in ~/.gtkrc-2.0.

5.2. GTK 3 and GTK 4

Unlike GTK 2, the config files for GTK 3 and GTK 4 are located in ~/.config/gtk-3.0/settings.ini and ~/.config/gtk-4.0/settings.ini, respectively. They both look similar, so we can populate the settings for GTK 4:

[Settings]
gtk-theme-name=Material-dark-compact
gtk-icon-theme-name=Adwaita
...

Now, for GTK 3, we’ll reuse this config file:

$ ln -sf ~/.config/gtk-4.0/settings.ini ~/.config/gtk-3.0/settings.ini

It effectively creates a symlink from GTK 4 settings to GTK 3 settings. So, the theme applies to both GTK 3 and GTK 4 applications. In addition, we can create a separate file for GTK 3 if we need to use a different theme for it.

6. GNOME Desktop

When we set the icons using the GNOME Tweaks, the changes apply to the GNOME desktop as well. However, we can change the desktop icon theme to a different theme separately:

$ gsettings set org.gnome.desktop.interface icon-theme 'Adwaita'

Let’s see how it works:

  • gsettings is a utility to interact with the centralized GSettings configuration system for GNOME
  • set applies a value to a specific GSettings key
  • org.gnome.desktop.interface is a GSettings schema that belongs to the desktop interface
  • icon-theme is the key in the specified schema
  • Adwaita is the name of the icon that we need to set

Once we set the icon theme, the icon theme for the GNOME desktop is updated, but the icon theme for the GTK applications remains intact.

7. Emblems

An emblem is an overlay that we can assign to files and folders to provide additional context. So, if we need to add additional emblems, we do so with xdg-icon-resource:

$ xdg-icon-resource install --context emblems --size 128 ~/Pictures/ubuntu.png ubuntu-logo

Let’s break this down:

  • xdg-icon-resource manages icon resources on a Linux system
  • install installs an emblem
  • –context emblem specifies that we’re installing an emblem
  • ~/Pictures/ubuntu.png is the name of the source image
  • ubuntu-logo is the name we give to the emblem

It puts the emblem in the ~/.local/share/icons directory. Now, if we need to use the emblem, we simply refer to it as ubuntu-logo.

8. Conclusion

In this article, we explored several ways to change the icon theme for GTK applications. We used GNOME Tweaks and LXAppearance to easily change the icon theme through a GUI. Afterward, we took a more hands-on approach by setting up the theme using the GTK configuration files.

Finally, we learned how to change the GNOME desktop icon theme as well as add additional emblems.

Comments are closed on this article!