Closed ashwinvis closed 6 years ago
Alternatively you could perform a split before comparing, but I am not sure how well that works for other DEs.
In [1]: import os
In [2]: de = os.environ.get('DESKTOP_SESSION')
In [3]: de
Out[3]: '/usr/share/xsessions/gnome'
In [4]: de.split('/')
Out[4]: ['', 'usr', 'share', 'xsessions', 'gnome']
In [5]: de.split('/')[-1]
Out[5]: 'gnome'
Or ...!
» echo $XDG_SESSION_DESKTOP
GNOME
EDIT: This wont work with i3. Bad idea.
At least in ArchLinux:
Which means this won't work:
https://github.com/markubiak/wallpaper-reddit/blob/52190f111d2a5381a8dd4b0fe0a90a5d08208b81/wpreddit/wallpaper.py#L35
This can be simply fixed as: