Web lists-archives.com

programmatically determining the desktop environment of a system

Is there a programmatic way that a piece of software can learn what
desktop environment it is executing in?

For example, i'm using xfce, and i can tell that i'm using xfce by
clicking on 'Applications' in the top menu bar and there's this item
that says 'About Xfce'; if you click on it it it looks like one of
these gtk about-windows.  (It even gives a version number.)

Could i identify the environment by inspecting the file system (for
example)?  (I imagine the answer there must be 'no', because different
users could have different environments but necessarily share the same
file system, but maybe i'm making some unjustified assumptions?)

TIA for any clues or thoughts on this.