How can I get to know what my desktop environment is using Python? I like the result to be gnome or KDE or else.
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