Ubuntu – apply a different GTK3 theme from the main one to an individual application

gnomegtk3themesunity

For example, can I keep Ambiance as main theme but assign elementary theme to elementary's app?

Best Answer

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

  1. Open your file browser
  2. Navigate to /usr/share/applications/
  3. Copy the launcher (highlight and Ctrl+C) for the app you want to launch with the elementary theme
  4. Navigate to ~/.local/share/applications/ and paste the launcher (Ctrl+V)
  5. Right-click and open the launcher with a text editor
  6. Modify the line starting with Exec= to include Exec=env GTK_THEME=elementary and then the previous existing contents of the line. (So Exec=pantheon-files would become Exec=env GTK_THEME=elementary pantheon-files)
  7. 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:

  1. Open your Terminal app
  2. Type alias pantheon-files="GTK_THEME=elementary pantheon-files" (replacing pantheon-files with the desired app)
  3. Press Enter

Caveats:

  1. This will not change your window manager's theme to the elementary theme.
  2. This (by design) will only apply to your account, not root or anyone else on the machine.
  3. The theme names are cAsE-sEnsItiVe and should be matched with the theme folder name.

Sources:

  1. I'm an elementary contributor ;)
  2. GTK+ 3 Reference Manual: Running GTK+ Applications
  3. Set variable in .desktop file