markubiak / wallpaper-reddit

Downloads and sets wallpapers pulled from reddit.com
GNU General Public License v3.0
113 stars 42 forks source link

DE detection needs some change in logic #44

Closed ashwinvis closed 6 years ago

ashwinvis commented 6 years ago

At least in ArchLinux:

» echo $DESKTOP_SESSION 
/usr/share/xsessions/gnome

Which means this won't work:

https://github.com/markubiak/wallpaper-reddit/blob/52190f111d2a5381a8dd4b0fe0a90a5d08208b81/wpreddit/wallpaper.py#L35

This can be simply fixed as:

...
elif check_de(de, ["gnome", "gnome-xorg", "gnome-wayland", "unity", "ubuntu", "budgie-desktop"]): 
...

def check_de(current_de, list_of_de):
    return any([de in current_de for de in list_of_de])
ashwinvis commented 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'
ashwinvis commented 6 years ago

Or ...!

» echo $XDG_SESSION_DESKTOP 
GNOME

EDIT: This wont work with i3. Bad idea.