Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #178944 > unrolled thread

programmatically determining the desktop environment of a system

Started byDan Hitt <dan.hitt@gmail.com>
First post2017-03-17 06:20 +0100
Last post2017-03-19 19:20 +0100
Articles 7 — 5 participants

Back to article view | Back to linux.debian.user


Contents

  programmatically determining the desktop environment of a system Dan Hitt <dan.hitt@gmail.com> - 2017-03-17 06:20 +0100
    Re: programmatically determining the desktop environment of a system Dominik George <nik@naturalnet.de> - 2017-03-17 06:50 +0100
    Re: programmatically determining the desktop environment of a system <tomas@tuxteam.de> - 2017-03-17 09:10 +0100
      Re: programmatically determining the desktop environment of a system Dan Hitt <dan.hitt@gmail.com> - 2017-03-18 04:20 +0100
        Re: programmatically determining the desktop environment of a system tomas@tuxteam.de - 2017-03-18 10:30 +0100
    Re: programmatically determining the desktop environment of a system Stefan Monnier <monnier@iro.umontreal.ca> - 2017-03-18 17:00 +0100
      Re: programmatically determining the desktop environment of a system Dan Hitt <dan.hitt@gmail.com> - 2017-03-19 19:20 +0100

#178944 — programmatically determining the desktop environment of a system

FromDan Hitt <dan.hitt@gmail.com>
Date2017-03-17 06:20 +0100
Subjectprogrammatically determining the desktop environment of a system
Message-ID<tlSsW-15A-1@gated-at.bofh.it>
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.

dan

[toc] | [next] | [standalone]


#178945

FromDominik George <nik@naturalnet.de>
Date2017-03-17 06:50 +0100
Message-ID<tlSVX-1l6-3@gated-at.bofh.it>
In reply to#178944
Hi,

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

Short answer: No.

Long answer:

http://unix.stackexchange.com/questions/116539/how-to-detect-the-desktop-environment-in-a-bash-script

Cheers,
Nik

[toc] | [prev] | [next] | [standalone]


#178946

From<tomas@tuxteam.de>
Date2017-03-17 09:10 +0100
Message-ID<tlV7r-3m4-15@gated-at.bofh.it>
In reply to#178944
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, Mar 16, 2017 at 10:17:37PM -0700, Dan Hitt wrote:
> Is there a programmatic way that a piece of software can learn what
> desktop environment it is executing in?

Just out of curiosity: what is (roughly) your use case?

(Personally I think it's a bad idea, but I'd like to learn)

regards
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAljLmC4ACgkQBcgs9XrR2kYBoACZAVOgMl1I2DyFdJSp1FMMy5eA
/rMAn0BTT1VByF5rhECqo47jAexuAFhG
=ucsZ
-----END PGP SIGNATURE-----

[toc] | [prev] | [next] | [standalone]


#178983

FromDan Hitt <dan.hitt@gmail.com>
Date2017-03-18 04:20 +0100
Message-ID<tmd4l-8t6-1@gated-at.bofh.it>
In reply to#178946
Thanks Dominik, Steve, and Tomas for your mail.

For reference, Steve Litt responded to me privately to consider first
running 'ps axjf' by hand, in which case the environment should be
obvious, presumably doing this in a few different environments, and
then attempting to write some parsing code which goes through the same
mental steps.   Certainly sounds reasonable absent an api, so thanks
Steve for the suggestion.

Thanks Dominik for the stack exchange link, which is basically the
same question (except that i would not be programming it in bash),
with some interesting ideas about environment variables to inspect.
(Part of the SE discussion in fact suggests using ps.)

Finally thanks for your response Tomas, with which i think most people
would agree.

That is, i think usually the best practice is to do capability
detection (like the autoconf apparatus or jquery does) and then use
whatever capabilities you detect.

I'm not sure this is always possible, though, because if it is
something about the using the hardware in a certain way you may not be
able to detect this (but rather rely on what you know about the
environment).

I was sort of hoping that somebody would answer saying "Use the foo()
function in the XYZ api".  Then at least i'd know to go find the XYZ
api and study it, because it would probably have a lot of other
goodies in it as well.  And i'm still interested in that, but given
Dominick's reference i'm kind of doubtful i'll find it.

Anyhow, thanks again everybody for your help!  :)

dan



On Fri, Mar 17, 2017 at 1:02 AM,  <tomas@tuxteam.de> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Thu, Mar 16, 2017 at 10:17:37PM -0700, Dan Hitt wrote:
>> Is there a programmatic way that a piece of software can learn what
>> desktop environment it is executing in?
>
> Just out of curiosity: what is (roughly) your use case?
>
> (Personally I think it's a bad idea, but I'd like to learn)
>
> regards
> - -- t
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.12 (GNU/Linux)
>
> iEYEARECAAYFAljLmC4ACgkQBcgs9XrR2kYBoACZAVOgMl1I2DyFdJSp1FMMy5eA
> /rMAn0BTT1VByF5rhECqo47jAexuAFhG
> =ucsZ
> -----END PGP SIGNATURE-----
>

[toc] | [prev] | [next] | [standalone]


#178988

Fromtomas@tuxteam.de
Date2017-03-18 10:30 +0100
Message-ID<tmiQp-489-3@gated-at.bofh.it>
In reply to#178983
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Mar 17, 2017 at 08:09:31PM -0700, Dan Hitt wrote:
> Thanks Dominik, Steve, and Tomas for your mail.
[...]

> That is, i think usually the best practice is to do capability
> detection (like the autoconf apparatus or jquery does) and then use
> whatever capabilities you detect.
> 
> I'm not sure this is always possible, though, because if it is
> something about the using the hardware in a certain way you may not be
> able to detect this (but rather rely on what you know about the
> environment).

Definitely, yes. But I see your point. Perhaps those two pointers might
help you a bit:

  https://metacpan.org/pod/Desktop::Detect
  https://www.freedesktop.org/wiki/Desktops/

(the second doesn't actually offer a method, but at least provides
you with a pretty extensive list of alternatives).

Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAljM/XUACgkQBcgs9XrR2kZ5bACfcGnW/8DeK2HJl6qhPV0pGLOW
TF8AnjaWibG/2b01kOp97JH22wneI/3Q
=gGPd
-----END PGP SIGNATURE-----

[toc] | [prev] | [next] | [standalone]


#178993

FromStefan Monnier <monnier@iro.umontreal.ca>
Date2017-03-18 17:00 +0100
Message-ID<tmoVP-70-3@gated-at.bofh.it>
In reply to#178944
> 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?)

That's right.  Most of my systems have both Gnome and XFCE installed at
the same time, and some of them have both active at the same time (for
different users running on different virtual terminals).

Also, the meaning of "desktop environment" is not completely clear
anyway: I've used the same programs (mostly ctwm, Emacs, Xterm, and
Firefox) for many years now, first without a so-called desktop
environment, then under Gnome2, then shortly under Gnome3 and now
under XFCE.  To the untrained eye, all 4 situations result in pretty
much the exact same behavior and the exact same appearance.


        Stefan

[toc] | [prev] | [next] | [standalone]


#179014

FromDan Hitt <dan.hitt@gmail.com>
Date2017-03-19 19:20 +0100
Message-ID<tmNAS-14Q-21@gated-at.bofh.it>
In reply to#178993
Thanks Stefan for your reply.

Stefan: i think you're right, that's sort of my experience as well,
although sometimes some programs feel more broken in one environment
than another.  (Like, with a certain desktop, iirc, some programs made
good use of having a right click on the dock, some didn't, and some
only got boiler plate icons or none at all on the dock.   I don't want
to name the desktop which showed these issues up in such stark relief
because my memory may be faulty, it is probably an old version by now,
and no point for me to be provocative over tentative plans!)

Thanks Tomas for the two links.  If i were programming in perl, the
first link would be right to the point.  And the second list looks
like it would be a good source to draw some testing targets from.

Thanks again everybody for the education.

On Sat, Mar 18, 2017 at 8:39 AM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
>> 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?)
>
> That's right.  Most of my systems have both Gnome and XFCE installed at
> the same time, and some of them have both active at the same time (for
> different users running on different virtual terminals).
>
> Also, the meaning of "desktop environment" is not completely clear
> anyway: I've used the same programs (mostly ctwm, Emacs, Xterm, and
> Firefox) for many years now, first without a so-called desktop
> environment, then under Gnome2, then shortly under Gnome3 and now
> under XFCE.  To the untrained eye, all 4 situations result in pretty
> much the exact same behavior and the exact same appearance.
>
>
>         Stefan
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.user


csiph-web