Can I apply a different GTK3 theme from the main one to an individual application?
You can use the GTK environment variable GTK_THEME=elementary
to launch an app with the elementary theme. For example, running GTK_THEME=elementary pantheon-files
will launch the elementary Files app using the elementary GTK theme.
To get this to apply every time you launch a specific app, your best option is likely to create a custom .desktop file (launcher).
Create a custom .desktop file
- Open your file browser
- Navigate to
/usr/share/applications/
- Copy the launcher (highlight and Ctrl+C) for the app you want to launch with the elementary theme
- Navigate to
~/.local/share/applications/
and paste the launcher (Ctrl+V) - Right-click and open the launcher with a text editor
- Modify the line starting with
Exec=
to includeExec=env GTK_THEME=elementary
and then the previous existing contents of the line. (SoExec=pantheon-files
would becomeExec=env GTK_THEME=elementary pantheon-files
) - Save and close the file
The next time you launch the app from Unity (or your app launcher of choice) it will use the elementary theme.
Bonus: make it work when using command line
You may also want the app to launch with the elementary theme when launching it from the command line. To do so:
- Open your Terminal app
- Type
alias pantheon-files="GTK_THEME=elementary pantheon-files"
(replacingpantheon-files
with the desired app) - Press Enter
Caveats:
- This will not change your window manager's theme to the elementary theme.
- This (by design) will only apply to your account, not root or anyone else on the machine.
- The theme names are cAsE-sEnsItiVe and should be matched with the theme folder name.
Sources:
- I'm an elementary contributor ;)
- GTK+ 3 Reference Manual: Running GTK+ Applications
- Set variable in .desktop file
The question is still valid and I found a way:
-
create any folder
path/to/MY_FOLDER
-
create a
/share/themes/
folder inside it (that ispath/to/MY_FOLDER/share/themes
). -
put any GTK3 theme inside the latter
-
rename the theme to the name of the CURRENTLY ACTIVE THEME.
At last, this command will make an app use the renamed theme instead of the currently active one:
GTK_DATA_PREFIX=path/to/MY_FOLDER YOUR_APPLICATON
(The path after GTK_DATA_PREFIX=
has to be that (and only that) to the folder that contains /share/themes/RENAMED_THEME
. That's why it's NOT path/to/MY_FOLDER/share/themes/RENAMED_THEME
, but just path/to/MY_FOLDER
.)
To have that inside a launcher, replace accordingly:
Exec=sh -c 'GTK_DATA_PREFIX=path/to/MY_FOLDER YOUR_APPLICATION'
Yes, the simple way is to point the application at the required path where your rc file lives, in the command that runs your application:
GTK2_RC_FILES=/usr/share/themes/Redmond/gtk-2.0/gtkrc inkscape
This on 12.04 for inkscape (which is still Gnome2 btw) produces this:
See more information about Gtk2 theme running here.