What is my current desktop environment?

前端 未结 4 1042
南笙
南笙 2020-12-31 23:39

How can I get to know what my desktop environment is using Python? I like the result to be gnome or KDE or else.

4条回答
  •  一生所求
    2021-01-01 00:08

    You might try this:

    def detect_desktop_environment():
        desktop_environment = 'generic'
        if os.environ.get('KDE_FULL_SESSION') == 'true':
            desktop_environment = 'kde'
        elif os.environ.get('GNOME_DESKTOP_SESSION_ID'):
            desktop_environment = 'gnome'
        else:
            try:
                info = getoutput('xprop -root _DT_SAVE_MODE')
                if ' = "xfce4"' in info:
                    desktop_environment = 'xfce'
            except (OSError, RuntimeError):
                pass
        return desktop_environment
    

    And read the discussion here: http://ubuntuforums.org/showthread.php?t=1139057

提交回复
热议问题