问题
I need to get the current Icon Theme in the system. The problem is that there are a lot of environments as GNOME, XFCE, MATE...
Please, how could I get the current Icon Theme? I'm thinking that it'll be with Gtk.IconTheme.get_default()
, but I didn't get a good result.
Thanks in advance!
回答1:
Unfortunately, there is no universal solution for all systems.
You will need to use different approaches depending on the environment, and then most likely include a switch depending on the present environment. It will take some research...
In modern gtk3 environments you can query and change basically any setting quite conveniently via gsettings
.
For example, in GNOME:
gsettings get org.gnome.desktop.interface icon-theme
will return the current icon-theme.
In Cinnamon, you can query similarly with:
gsettings get org.cinnamon.desktop.interface icon-theme
in Mate, the key icon-theme
would be defined in schema org.mate.interface
, and under Xfce the available tool is xfconf-query:
xfconf-query -lvc xsettings -p /Net/ThemeName
With window managers you can read the appropriate config files like for example gtk-icon-theme-name=
from $HOME/.gtkrc-2.0,
or it might even be defined in ~/.Xresources, or (rather outdated) in $HOME/gtk-3.0/settings.ini, possibly also in $HOME/.config/qt5ct/qt5ct.conf ;) ... and so on :)
来源:https://stackoverflow.com/questions/28779868/how-to-get-the-current-linux-theme-with-python