Author Topic: Why is it so hard to write a gui script for multiple DE?  (Read 2915 times)

Online muungwana

  • Hero Member
  • *****
  • Posts: 6201
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #15 on: December 04, 2010, 02:47:29 PM »

All desktop environments are started by a script called "startN" where N is kde for kde desktop, gnome for gnome desktop, fluxbox for fluxbox windows manager and i am sure it is the same for all of them.

All that is required is adding a variable in each script setting a global variable and then any script will easily check for the desktop environment in use.

This seem to be the easiest way to go about doing this
.. 3 things are certain in life : death, taxes and software bloat ..
.. tell me something i don't know, something i can use as i struggle to reason with the world around me ..

Online pinoc

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2847
    • other projects...
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #16 on: December 04, 2010, 02:50:05 PM »
pinoc,
I should have said "some slight differences," I think. The differences I was referring to are those in the other DEs.

In LXDE, lxde-logout is available. (Not used in Melodie's openbox, I think.) I posted it previously, but Martin appears to have had an objection to it. So perhaps lxsession? Hmm... ~/.config/lxsession/LXDE/desktop.conf shows window_manager=openbox-lxde. So perhaps a test for openbox-lxde?



Hi Neal,
I only have the folders lxpanel and lxterminal in ~/.config/. In any case, any LXDE-specific config-file will also be there when both, LXDE and OpenBox, are installed on the system. However, I just found this to work to distinguish LXDE from OpenBox:
Code: [Select]
LXDEWM=`ps -ef|grep lx|wc -l` && echo $LXDEWM This will return 4 or 5 in LXDE and 0 or 1 in OpenBox. You can get 2 answers depending if the command itself is counted or not. Just enter the command several times to verify. Anyway, a simple if the result is larger than 2 will be enough to distinguish between LXDE and OpenBox.  ;)
best,
-p.


Offline xircon

  • Jr. Member
  • **
  • Posts: 11
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #17 on: December 04, 2010, 03:00:49 PM »
What about:
Code: [Select]
echo $DESKTOP_SESSION

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #18 on: December 04, 2010, 03:03:17 PM »
pinoc,
Yes. I get a result of 5 from that script. :)

muungwana,
That might do the trick indeed.

xircon,
Good one.

Online pinoc

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2847
    • other projects...
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #19 on: December 04, 2010, 03:08:37 PM »
What about:
Code: [Select]
echo $DESKTOP_SESSION

Xircon,
Works on all DEs mentioned before. Great hint! Clearly the best solution, and so easy... ::)
-p.

Offline xircon

  • Jr. Member
  • **
  • Posts: 11
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #20 on: December 04, 2010, 03:10:41 PM »
I used it in a Free Pascal program a while back:

Code: [Select]
Tdtop:=fpGetenv('DESKTOP_SESSION');

Online muungwana

  • Hero Member
  • *****
  • Posts: 6201
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #21 on: December 04, 2010, 03:40:18 PM »
[ink@mtz ~]$ echo $DESKTOP_SESSION

[ink@mtz ~]$

its not set here, what desktop are you using and what result did you get?
.. 3 things are certain in life : death, taxes and software bloat ..
.. tell me something i don't know, something i can use as i struggle to reason with the world around me ..

Online pinoc

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2847
    • other projects...
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #22 on: December 04, 2010, 04:16:07 PM »
[ink@mtz ~]$ echo $DESKTOP_SESSION

[ink@mtz ~]$

its not set here, what desktop are you using and what result did you get?

Hi muungwana,
knowing you as a KDE fan I assume your result is from a KDE-session? On my multiDE install and logged into KDE the result for that command was 01KDE. But on FullMonty (which is KDE) I got default instead of 01KDE, and you got no output at all.
Maybe the command echo $DESKTOP_SESSION is not working in all cases? At least the output of wmctrl -m on FullMonty as well as other KDE installations I have (multiDE and single KDE) are consistent. What do you get for wmctrl -m on the machine where echo $DESKTOP_SESSION results in no output?
-p.

Offline Mark342

  • Sr. Member
  • ****
  • Posts: 334
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #23 on: December 04, 2010, 04:31:12 PM »
I've always wondered how to do this too.
You can do
Code: [Select]
echo $DESKTOP_SESSION
To find out which session is running, but if I am logged into KDE (the DE that came on the ISO) it reports "default".

You can use this to check if KDE is running
Code: [Select]
if [ -n $KDE_FULL_SESSION ]
then
...
fi
http://techbase.kde.org/KDE_System_Administration/Environment_Variables#Automatically_Set_Variables

I can't find any info for GNOME environment variables
If we can get some info on the output of
Code: [Select]
env | grep <name of currently running DE here in capital letters>We might be able to find out.

Anything worth doing is worth overdoing.

Registered Linux user #493318
Register yourself here: Linux Counter

Offline xircon

  • Jr. Member
  • **
  • Posts: 11
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #24 on: December 04, 2010, 04:34:05 PM »
Reports "O2GNOME" I'll let you guess what I am running :) Only got Gnome installed.

Online muungwana

  • Hero Member
  • *****
  • Posts: 6201
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #25 on: December 04, 2010, 04:46:17 PM »
Code: [Select]
[ink@mtz ~]$ wmctrl -m
X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  20 (X_GetProperty)
  Resource id in failed request:  0x180010c
  Serial number of failed request:  11
  Current serial number in output stream:  11
[ink@mtz ~]$
yes, i use KDE4 but build from source from KDE servers.

That command doesnt work here, does it produce a window? I build KDE from source and i use a different oxygen package to enable QT application transparency and some GUI apps refuses to run i suspect because of it, the other i know of that produce that kind of error is xine.

I suspect variable is set by log in manager(kdm,gdm) and hence may produce different results depending on what manager is in use. Do use the same manager on both of your installs?
.. 3 things are certain in life : death, taxes and software bloat ..
.. tell me something i don't know, something i can use as i struggle to reason with the world around me ..

Online pinoc

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2847
    • other projects...
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #26 on: December 04, 2010, 04:57:32 PM »
Hi muungwana,
thanks for the info. wmctrl is a nice little app to get info on the running DE and to manage desktops and windows of running applications. For example, I use it in getopenoffice to check for and close running OO-instances before installing OO. This command has always worked for me and now maybe not for you because you use a non-PCLOS KDE version? Don't know, and don't think so actually, if the result depends on the use of kdm or gdm, I don't use gdm but kdm on any installation I have (you know, as little Gnome-stuff as possible...  ;D ;D ;D )
-p.

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #27 on: December 04, 2010, 05:04:13 PM »
Maybe

Code: [Select]
env | grep DESKTOP_SESSION
In KDE it returns  01KDE  and in Enlightenment it returns  23E17 ....  on this install.

EDIT
            Oops it appears not to return KDE for some ...... 

Online muungwana

  • Hero Member
  • *****
  • Posts: 6201
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #28 on: December 04, 2010, 05:14:27 PM »

This is what i am getting now
Code: [Select]
[ink@mtz ~]$ echo $DESKTOP_SESSION
kde
[ink@mtz ~]$

So it does return "kde" afterall :D

I am playing around here and is started the desktop with "startx" after i logged it from the the terminal and i as i wrote earlier, i suspect the variable is set by a log in manager and mine was empty earlier because the desktop was not started by a log in manager.

It will be useful if people would mention what log in manager they use when reporting their result
.. 3 things are certain in life : death, taxes and software bloat ..
.. tell me something i don't know, something i can use as i struggle to reason with the world around me ..

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #29 on: December 04, 2010, 05:18:44 PM »
Have a look in /etc/X11/dm/Sessions and in /etc/X11/dm.d. The files in these will give you info on what is available.

edit: Also look in /etc/X11/wmsession.d.

I suggest these simply as a way to gather info.
« Last Edit: December 04, 2010, 05:35:19 PM by Neal »