-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_desktop
executable file
·51 lines (43 loc) · 1.48 KB
/
get_desktop
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
from platform import system
from platform import release
from os import environ
# helpful info from neofetch's get_de function on line 1771
# https://github.com/dylanaraps/neofetch/blob/master/neofetch
# more info
# https://superuser.com/questions/1074068/what-is-the-difference-between-desktop-session-xdg-session-desktop-and-xdg-cur
def get_de():
"""returns the desktop environment or an error"""
os = system()
if os == "Windows":
if release() == 10:
return "fluent"
if release() == 8:
return "metro"
# else
return "aero"
elif os == "Darwin": # refers to mac
return "aqua"
elif os == "Linux":
# returns a string with list items seperated with colons
try:
desktops_env = environ["XDG_CURRENT_DESKTOP"]
except KeyError:
# this means the variable isn't set
return "XDG_CURRENT_DESKTOP env not found"
else:
recognised_desktops = [
"gnome", "plasma",
"mate", "xfce",
"cinnamon", "deepin",
"budgie", "lxqt",
"lumina", "trinity",
"unity"
]
for desktop in recognised_desktops:
if desktop in desktops_env.lower():
return desktop
# if the function hasn't returned already
return "de not recognised"
if __name__ == "__main__":
print(get_de())