This article explains how to apply other GTK 3 themes to specific applications (themes other than global / desktop GTK themes).
So why do you need to set some applications to use a different GTK3 theme than the theme set for the entire desktop? In some cases, an application does not look as expected / looks corrupted by a particular theme, but you want to continue using that theme for other applications on your Linux desktop. Alternatively, you may prefer to use only one specific theme for one or two applications and other themes, for example you can set your text editor to use a dark theme and a light theme All other applications on the desktop.
|In this screenshot, Tweaks uses the Mint-Y theme, Nautilus uses the Canta theme, Gedit uses Yaru-dark, and the Eolie web browser (installed from Flathub) uses the Plata theme. They all run at the same time.|
Let me give you an example.
By default, Ubuntu 19.10 uses a light and dark mixed theme, but is different from the theme used in earlier Ubuntu versions: the window title is dark, but the menu bar is now bright. So by default, Visual Studio Code using dark themes, code editors like Atom or Sublime Text have a white menu bar and all other menu items are dark.
If you wish to keep this setting (Yaru theme as global GTK 3 theme, dark theme as VS Code / Atom / Sublime Text, then change VS Code / Atom / Sublime Text menu bar to dark, so don’t Forgot, you can use the instructions in this article to set VS Code / Atom / Sublime Text to use Yaru-dark theme while letting all other applications use the default hybrid Yaru theme. Get dark on Ubuntu 19.10 with Yaru theme GNOME Shell menus and dialogs To change the GTK theme on a per-application basis, we will use
GTK_THEME Environment variable, according to which “is mainly used to easily debug theme issues” This GNOME GTK page. Therefore, there is no guarantee that this option will be available everywhere (actually not applicable for DBus activated applications) and that it may sometimes stop working.
It is worth mentioning that this changes the application theme for all GTK 3 applications, but for applications that do not use client decoration, the window decoration remains the same (continue to use the global GTK 3 theme). This works for native apps, as well as Flatpak and Snap packages, as long as Flathub / Snapcraft supports the theme you want to use for a particular application (note that the Flatpak application supports more third-party themes than Snap).
Launch a single application with a theme different from the global GTK3 theme
To override the default GTK theme on a per-app basis, set
GTK_THEME An environment variable that uses the theme you want the application to use as its value when the application is launched. like this:
You need to replace
And theme name (for example, the theme displayed in the Tweaks application), and
It’s important to note that before running the application with a custom theme, you need to close all running instances of the application (in case it runs in the background, you can kill it, such as killing all running Nautilus instance:
Let’s look at an example. Suppose you want to start Gedit with Yaru-dark as the theme:
Or launch Nautilus (File App) with Canta as the theme and keep other themes set for other apps:
If the theme you want to set has a dark variant but not separate, specify that you want to use a dark theme like this:
GTK_THEME=theme-name:dark. For example, to make an application use the Adwaita dark theme (it does not have a separate Adwaita-dark folder, but does have dark theme support), launch the application as follows:
Always launch specific apps with custom GTK 3 themes
You need to do this if you want to launch an application with a specific GTK 3 theme (different from the desktop GTK theme) every time you click the application’s icon in the application menu or launcher.
Start by copying the application’s desktop files
~/.local/share/applications. If you edit the desktop file directly in
/usr/share/applications, The desktop file is overwritten every time the application is updated, so you have to redo it once. But by copying the desktop files to
~/.local/share/applications, These changes will be retained through the upgrade (and will only affect your users).
Next, open the application desktop file (located at
~/.local/share/applications) And text editor (such as Gedit) to find the line that starts with
env GTK_THEME= With one
With the name of the theme (such as the theme displayed in the Tweaks application), but do not make other modifications.
The example assumes that you want to force VS Code to use Yaru-dark as its theme, while using a different theme for all other applications on the desktop. In this case, please copy
code.desktop File from
code.desktop Use a text editor from this new location and find
The original VS Code desktop file (code.desktop) has the following
Exec=/usr/share/code/code --unity-launch %F
After editing it to force VS Code to use the Yaru-dark theme, this line becomes:
Exec=env GTK_THEME=Yaru-dark /usr/share/code/code --unity-launch %F
If the application has multiple
Exec Rows (for example, if the application desktop file supports desktop actions that appear when you right-click the application icon), do this for each row. Remember to close all running application instances before running the application with a custom theme!
Pass r / Ubuntu (U / manyfacedgodd)