11#!/usr/bin/env python3
22
3- PYFETCH_VERSION = "1.1.02 " # Changing the version in this line is highly not recommended.
3+ PYFETCH_VERSION = "1.1.03 " # Changing the version in this line is highly not recommended.
44import os
55
66# Load ~/.config/pyfetch/pyfetch.conf
@@ -19,8 +19,6 @@ def load_conf(path):
1919 key , value = line .split ('=' , 1 )
2020 config [key .strip ()] = value .strip ().lower ()
2121 return config
22-
23- # Load config
2422cfg = load_conf (os .path .expanduser ("~/.config/pyfetch/pyfetch.conf" ))
2523
2624import platform
@@ -144,6 +142,17 @@ def get_package_count():
144142
145143pkg_count = get_package_count ()
146144
145+ # Get Desktop Environment
146+ def get_desktop_environment ():
147+ de = os .environ .get ("XDG_CURRENT_DESKTOP" ) or os .environ .get ("DESKTOP_SESSION" ) or "Unknown"
148+ if "KDE" in de .upper () or "PLASMA" in de .upper ():
149+ return f"KDE Plasma (You have great taste!)"
150+ if "Zorin" in de .upper ():
151+ return f"GNOME"
152+ return de
153+
154+ de = get_desktop_environment ()
155+
147156# Turn entire base of PyFetch to 1 command
148157def pyfetchbase ():
149158 if cfg .get ('ascii_art' , 'true' ) == 'true' :
@@ -154,6 +163,8 @@ def pyfetchbase():
154163 print (f"User: { getpass .getuser ()} " )
155164 if cfg .get ('show_kernel' , 'true' ) == 'true' :
156165 print (f"Kernel: { platform .system ()} { platform .release ()} " )
166+ if cfg .get ('show_de' , 'true' ) == 'true' :
167+ print (f"Desktop Environment: { de } " )
157168 if cfg .get ('show_packages' , 'true' ) == 'true' :
158169 if pkg_count is not None :
159170 print (f"Packages: { pkg_count } " )
@@ -176,6 +187,7 @@ def pyfetchbasenonconfig():
176187 print (f"Hostname: { socket .gethostname ()} " )
177188 print (f"User: { getpass .getuser ()} " )
178189 print (f"Kernel: { platform .system ()} { platform .release ()} " )
190+ print (f"Desktop Environment: { de } " )
179191 if pkg_count is not None :
180192 print (f"Packages: { pkg_count } " )
181193 else :
@@ -196,6 +208,8 @@ def nopluginsbase():
196208 print (f"User: { getpass .getuser ()} " )
197209 if cfg .get ('show_kernel' , 'true' ) == 'true' :
198210 print (f"Kernel: { platform .system ()} { platform .release ()} " )
211+ if cfg .get ('show_de' , 'true' ) == 'true' :
212+ print (f"Desktop Environment: { de } " )
199213 if cfg .get ('show_packages' , 'true' ) == 'true' :
200214 if pkg_count is not None :
201215 print (f"Packages: { pkg_count } " )
0 commit comments