如何使用Python获取当前的Linux主题? [英] How to get the current Linux theme with Python?

查看:140
本文介绍了如何使用Python获取当前的Linux主题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在系统中获取当前的图标主题.问题是有很多环境,例如GNOME,XFCE,MATE ...

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...

请,我如何获取当前的图标主题?我以为它将与Gtk.IconTheme.get_default()一起使用,但是我没有得到很好的结果.

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.

提前谢谢!

推荐答案

不幸的是,并非所有系统都具有通用解决方案.

Unfortunately, there is no universal solution for all systems.

您将需要根据环境使用不同的方法,然后很可能根据当前环境使用开关.需要进行一些研究... 在现代gtk3环境中,您可以非常方便地通过gsettings查询和更改任何设置. 例如,在GNOME中:

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

Mate 中,键icon-theme将在模式org.mate.interface中定义,并且在 Xfce 下可用的工具是 xfconf-query :

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

使用窗口管理器,您可以从 $ HOME/.gtkrc-2.0
中读取相应的配置文件,例如gtk-icon-theme-name= 或者甚至可以在〜/.Xresources 中定义,或者(而不是过时)在 $ HOME/gtk-3.0/settings.ini 中定义,也可以在 $中定义HOME/.config/qt5ct/qt5ct.conf ;)...依此类推:)

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 :)

这篇关于如何使用Python获取当前的Linux主题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆