Change the theme for GTK applications

Recently, I needed a text editor Geany. I installed, configured and decided to write a little guide, a cheat sheet to change the theme a specific application. I use the distro is Fedora 31, but this instruction is suitable for almost any distro with a GNOME desktop. As we know gnome has a “Spartan” options to choose from. Good or bad, I will not argue and will understand how to fix it.

The developers of GNOME and many distributions, each in its own set up the application. In spring, the GNOME developers even wrote an open letter asking destructrices, do not change the default settings of GNOME applications. Also the Internet can download and install any themes and icons to your taste.

How to change the theme for GTK applications

In the GNOME desktop I use the light theme Adwaita. You have, in your distribution and personal preferences can be any other subject. As you can see by the title, I want to change the theme of one (or more) of GTK applications.

So let’s begin. As we know the application Gnome-tweak changes the subject all applications in the system.
For example bright:

Or dark:

Also there are exceptions of distractedly or GNOME developers. For example, I have the bright Adwaita application Eye of GNOME (eog) and Totem appear in dark theme:

Also in the screenshot I have inserted the video player Celluloid, it is not included in the standard set gnomovsky applications, but also comes with a dark theme. Although in the app’s settings you can change on the light.

About the same want to do and I need me app. For example I take the text editor Geany. By default I have it looks like this:

I want to make it look similar to the official website of Geany:

Go to the website of Geany: https://www.geany.org/ . Further link : https://github.com/geany/geany-themes download the ZIP file with themes, unpack and install (script install.sh or by copying the directory ~/.config/geany/colorschemes/).

Enable in settings Geany any dark theme to your taste View => Color schemes.

Here we see the dark terminal inside the light application. Not quite as I would like.

Go ahead. Try to include GtkInspector. This app is a tool for checking changes and understanding of GTK+ on the fly. In Debian / Ubuntu , make sure that you have installed the package libgtk-3-dev. Type in the terminal:

gsettings set org.gtk.Settings.Debug enable-inspector-keybinding true

We have included GtkInspector. To start GTKInspector, focus your GTK application and hit Control-Shift-d Or move the mouse pointer over the desired widget and click Control-Shift-I to specifically check the widget under the mouse cursor.

Start GtkInspector. It is included only in the window running the application.

Go to the tab appearance and turn Dark (or theme Adwaita-dark):

As you can see we get the desired result, the application Geany theme changed to dark. Close GtkInspector. It until I don’t need (further it will be required to verify changes). You can see here and play with him. This is a pretty interesting tool and worthy of a separate study.

Try to restart the app Geany:

And what do we see? Dark theme is not preserved. Geany opened again to light the subject. You need to look for another solution, but nothing “Normal heroes always go around” Aybolit – 66 movie.

Now we try to tightly bind the Geany – dark theme. Under the guide of GTK+, you can load a specific theme and version of it (dark, light) for each application using the following environment variable: GTK_THEME=theme:variant . And to add to the file at:

/usr/share/applications/"application name".desktop

the command env (allows to modify the list of environment variables before the execution of a custom command) in the string Exec. Where “application name” – the name of the application. In my case the line in the file:

/usr/share/applications/geany.desktop

should look like this:

Exec=env GTK_THEME=Adwaita:dark geany %F

If we need light theme line should look like this:

Exec=env GTK_THEME=Adwaita:ligh geany %F

The topic can tightly bind in two ways. The first option is to bind in root of the system at:

 /usr/share/applications/geany.desktop

For all users, or the second option is to tie into the home directory at:

~/.local/share/applications

For the current user. I prefer and recommend you to store various user settings in the home directory, but will consider both.

Change the theme for the current user

Open and edit the file run:

sudo nano /usr/share/applications/geany.desktop

Find the line:

Exec=geany %F

add an entry

env GTK_THEME=Adwaita:dark

and bring to mind :

Exec=env GTK_THEME=Adwaita:dark geany %F

Save and run Geany:

As you can see it works.

Restart GtkInspector, go to the tab appearance, try to switch the subject. Change the subject of the blocked (shaded and inactive), when you hover the mouse over the switch window appears that says “the Theme is coded with the help of GTK_THEME” (sorry I technically can’t show the popup on the screenshot). As you can see we are severely tied dark theme to the app Geany, and change the topic.

Change the theme for all users

Copy the file geany.desktop in the home directory .local/share/applications through terminal:

cp-r /usr/share/applications/geany.desktop ~/.local/share/applications

Or you can use the file Manager Nautilus. Then open the copied file:

~/.local/share/applications/geany.desktop

.

As in the first case we find the line:

Exec=geany %F

Will edit and bring to mind:

Exec=env GTK_THEME=Adwaita:dark geany %F

And also check:

As you can see here it works. To ‘reset’ a theme, you can edit the file in the root or edit (or delete) file in your home directory.

Thus you can change the subject one or more applications to your taste. It should be noted that according to the decision of the developers of Gnome-terminal has its own settings and ignores the topic. In addition, some apps GTK may not follow variable: env GTK_THEME. But it is always possible to check the program GtkInspector.

Source: losst.ru

(Visited 46 times, 2 visits today)