Detecting OS and Window Manager

Sean 'Shaleh' Perry shalehperry at attbi.com
Wed Jun 5 15:12:06 EDT 2002


On 05-Jun-2002 Andrew Wilkinson wrote:
> Hi,
> 
> I'm writing a program that integrates with a number of different OSes and
> Window Managers (under Linux), but I need to check what the user is running.
> I know that...
> 
> import os
> if os.name == 'nt':
> 
> will tell me they're running NT. But under Linux I'd like to know if they
> are running KDE or Gnome, does anyone know a (preferably) simple test for
> this?
> 

the only fool proof way to detect KDE, GNOME, etc is to check for X atoms.  The
bigger question is why do you care?  As long as they can display a GUI you
should not be bothered about which one it is.  Especially under the X Window
System it was designed so that random applications DIDN'T know what they were
running under.

Also remember KDE is not a window manager, it is a desktop environment.  It is
perfectly reasonable to run KDE and use fvwm (or even twm) as the window
manager.  Same applies to GNOME.  Also, what about someone who only runs say
Window Maker and never uses GNOME or KDE?





More information about the Python-list mailing list