Detecting OS and Window Manager

Mike Clarkson support at internetdiscovery.com
Fri Jun 14 01:36:20 EDT 2002


On Wed, 05 Jun 2002 12:12:06 -0700 (PDT), "Sean 'Shaleh' Perry"
<shalehperry at attbi.com> wrote:

>
>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?
 
This is quite a hard problem because of the possible DeskTop and
window manager combinations. For a stab at a solution (in part using X
atoms), take a look at the logic in the WmDefault style of tix 8.1.3
on http://tix.sourceforge.net/. The logic is in Tcl, but it is used by
Tix in Python.

>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.

There can be a number of reasons you'd care. For example, if you are
using TkInter, you may want it to pick up the user's default settings
for that environment for things like colors and styles.  If you are
using CDE/KDE/GNOME, then Tix.Tk() should(*) pick these up using
the WmDefault style, whereas Tkinter.Tk() won't, except under Windows.

>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?

Each case has to be checked and as you point out,  X atoms are the
safest.

Mike.



More information about the Python-list mailing list