[Tutor] Checking the desktop environment
Timo
timovwb at gmail.com
Fri Jun 20 20:48:49 CEST 2008
Thanks for your explanation. Apparently it's not possible to detect it
in all cases, but it would be nice to detect it for regular users, so
people who have a default install.
Well, my program needs a text-editor and a graphical box for
root-password. So it checks for the desktop environment so it could set
these things to gedit and gksudo for Gnome and kate and kdesu for KDE.
Timo
Alan Gauld schreef:
> "Timo" <timovwb at gmail.com> wrote
>
>> Hello all, in my program I need to know what desktop environment the
>> user is running.
>
> A few years ago I would have said that meant you had a broken
> design since it was very bad practice for any program to depend
> on the users environment. nfortunately recent developments in
> Linux/X mean that the whole concept is broken that one more
> environmentally wawre program probably is no big deal!
>
> But there are caveats that mean you will probably never get
> it right in every case. The best you cvan probably do is detect
> if the environment is one of a fixed set known to work with
> your code.#
>
> But bear in mind that the user can switch envirojnemts while
> your code is running, or may even be runningmultiple
> environments simultaneously on virtual windows etc.
>
> Thats why the users environment should be left as as
> something for the user and the programming environment
> for the programmer.
>
>> I figured this piece of code works, but apparently not
>> on every Linux distro. On Ubuntu it did the trick, but then I heard of
>> someone who runs SLiM that he get's an error with this.
>>
>> if os.environ['DESKTOP_SESSION'].startswith('kde'):
>> print "Running KDE"
>
> That would only find out if KDE was beiong used and only
> if the user (or cofig scripts) has not modified the variable.
>
>> So, does anyone know a water-proof solution for desktop environment
>> checking?
>
> I don't think such a thing can exist on a Unix/X system. An
> approximation will be the best you can get.
>
> Can you explain why you need to know?
> In most situations there should be a generic way to do it.
>
>
> Alan G.
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list