Most common scenario, you installed a program that looks horrible or unreadable on your current theme or variation of that theme (light, dark). There's a simple workaround for most programs to fix this problem.
For GTK 2, just use the GTK_RC_FILES
variable to tell the program which theme it's going to use. For example:
$ GTK2_RC_FILES=/usr/share/themes/Adwaita-dark/gtk-2.0/gtkrc gimp
Executing the program from the command line like that, will indicate that gimp
has to use your Adwaita-dark
theme, that's installed in /usr/share/themes/
directory (default path in most distros). This will work only that time and only when using that command indicating the correct location of the gtkrc
file belonging to the theme you want to apply, no permanent changes to how it will open next time if using only gimp
from the command line.
For GTK 3, you can use the GTK_THEME
variable.
$ GTK_THEME=Adwaita:dark gimp
Once again, we can run gimp
using the Adwaita:dark
theme, this time there's no need to actually use the full path to the one we want to apply, just the name as it appears in the Appearance config panel. The same as above, this will only work just once and makes no permanent changes.
There are two workarounds to make this changes more "permanent".
Just locate your program .desktop
file. Most distros place this files in /usr/share/applications
or you can also find it in your Home directory, in ~/.local/share/applications/
. Either way, just open the shortcut with your favourite editor and look for the Exec=
line that tells that shortcut what to execute. There you can add the following:
- GTK 2
[Desktop Entry]
...
Exec=env GTK2_RC_FILES=/usr/share/themes/Adwaita-dark/gtk-2.0/gtkrc gimp
...
- GTK 3
[Desktop Entry]
...
Exec=env GTK_THEME=Adwaita:dark gimp
...
Add to your .alias
config file of choice a new alias for your program to be called from the command line.
...
alias gimpdark='GTK_THEME=Adwaita:dark gimp'
...
In some cases neither solution will work to actually force the theme on the program you need to run. In that case you could just try to for it using xprop
and xdotool
like this:
#!/bin/bash
/bin/spotify &
sleep 0.2
xprop -f _GTK_THEME_VARIANT 8u -set _GTK_THEME_VARIANT "dark" -id $(xdotool getactivewindow)
The example is an script that will force the dark variant of the current theme on the spotify
program on execution. For this to work obviously you need to close any instance of the program you want to force to do this and execute the script instead of the program itself.
Sources: