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

Offline pinoc

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2880
    • other projects...
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #30 on: December 04, 2010, 05:30:09 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.


yes, and/or from a cmd-line enter chksession -L  good to find out what DEs are available.  ;)
This is strange: echo $DESKTOP_SESSION on a 2010.11 live-session results in 01KDE, after install the result is default  :P
better catch some sleep now,
-p.

Offline melodie

  • Hero Member
  • *****
  • Posts: 5945
  • Internet Relay Chat sur Freenode
    • PCLinuxOS Fr
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #31 on: December 04, 2010, 07:48:32 PM »
Hi,

Why do we have to use kdesu and gksu when a program that makes it for all DE and is most lightweight exist ?

Have you ever looked or tried ktsuss ?

melodie at #lpic-fr on irc.freenode.net

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15829
  • LXDE! Coffee, Bacon and Cheesecake!
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #32 on: December 04, 2010, 07:53:16 PM »
Hi,

Why do we have to use kdesu and gksu when a program that makes it for all DE and is most lightweight exist ?

Have you ever looked or tried ktsuss ?


ktsuss is a replacement for gksu, not kdesu. Using it, the check would be between kdesu and ktsuss. Back to the same thing, but with one utility being different.


Offline melodie

  • Hero Member
  • *****
  • Posts: 5945
  • Internet Relay Chat sur Freenode
    • PCLinuxOS Fr
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #33 on: December 04, 2010, 08:23:02 PM »
Hi,

Why do we have to use kdesu and gksu when a program that makes it for all DE and is most lightweight exist ?

Have you ever looked or tried ktsuss ?


ktsuss is a replacement for gksu, not kdesu. Using it, the check would be between kdesu and ktsuss. Back to the same thing, but with one utility being different.




Except that : ktsuss does not need any particular environment to work with. You can use in in any of them. The only trouble, would be to get rid of all the calls to kdesu in the KDE versions systems. :)

melodie at #lpic-fr on irc.freenode.net

Offline xircon

  • Jr. Member
  • **
  • Posts: 11
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #34 on: December 05, 2010, 01:25:27 AM »
Another thought:
Code: [Select]
pidof gnome-session
2421

Each DE must have a "unique" process that can be tested for in memory.

Cheers

Steve

Offline pinoc

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2880
    • other projects...
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #35 on: December 05, 2010, 03:07:01 AM »
Another thought:
Code: [Select]
pidof gnome-session
2421

Each DE must have a "unique" process that can be tested for in memory.

Cheers

Steve

good idea. Unfortunately a ps -ef|grep session works only for the major DEs but not for pekwm, openbox, fluxbox, blackbox, and afterstep.  :(

Offline xircon

  • Jr. Member
  • **
  • Posts: 11
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #36 on: December 05, 2010, 03:44:38 AM »
Just installed AfterStep (as I have never heard of it!).  Seems to work for me:
Code: [Select]
[xircon@localhost ~]$ pidof afterstep
787
[xircon@localhost ~]$ pidof gnome-session
[xircon@localhost ~]$

Offline pinoc

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2880
    • other projects...
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #37 on: December 05, 2010, 05:52:23 AM »
Just installed AfterStep (as I have never heard of it!).  Seems to work for me:
Code: [Select]
[xircon@localhost ~]$ pidof afterstep
787
[xircon@localhost ~]$ pidof gnome-session
[xircon@localhost ~]$

The pid will always be different for each session of the same DE. You can test that by a logout/login and then run the command again.

One could do a
Code: [Select]
ps -ef |grep X|wc -l where X is a placeholder for the DE and the result is 2 or larger for a given DE. To detect a given DE replace X with (DE in parenthesis): afterstep (afterstep), blackbox (blackbox), enlightenment (e17), fluxbox (fluxbox), metacity (Gnome), icewm (IceWM), kdeinit4 (KDE), lx (LXDE), openbox (OpenBox), pekwm (PekWM), xfce4 (XFCE). So for example to detect Gnome:
Code: [Select]
ps -ef |grep metacity|wc -l The problem here is that this will only work if no other applications are running, as they will influence the counting. For example if you open a lxterminal in KDE and then check for LXDE the above command will output 2, so it can not be used in this case.  :-\
wmctrl still seems to be the safest option for me, maybe combined with $DESKTOP_SESSION
-p.

Offline xircon

  • Jr. Member
  • **
  • Posts: 11
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #38 on: December 05, 2010, 06:34:06 AM »
No, what I meant was you could test for each desktop environment, if a PID is returned, then that DE is running.

Code: [Select]
#! /bin/bash
#I run Gnome!!
a=$(pidof gnome-session)

b=$(pidof afterstep)

c=$(pidof dont-have-kde)

echo "*"$a"*"
echo "*"$b"*"
echo "*"$c"*"

The "*" where just to test the contents of the variable did not contain any spaces.  Then test along the lines of
Code: [Select]
if [[ $a -ne "" ]]; then
You just need a unique process name per DE.

Could get a bit long winded if you covered all DE :)

:Edit:  This can be done more elegantly obviously, stuffed full of cold, so am thinking through a bucket of custard at the moment!!
« Last Edit: December 05, 2010, 06:52:31 AM by xircon »

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6849
  • MLU
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #39 on: December 05, 2010, 07:09:24 AM »


:Edit:  This can be done more elegantly obviously, stuffed full of cold, so am thinking through a bucket of custard at the moment!!


cold custard ......   mnnnnnn     :D

Offline pinoc

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2880
    • other projects...
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #40 on: December 05, 2010, 12:05:01 PM »
No, what I meant was you could test for each desktop environment, if a PID is returned, then that DE is running.

Code: [Select]
#! /bin/bash
#I run Gnome!!
a=$(pidof gnome-session)

b=$(pidof afterstep)

c=$(pidof dont-have-kde)

echo "*"$a"*"
echo "*"$b"*"
echo "*"$c"*"

The "*" where just to test the contents of the variable did not contain any spaces.  Then test along the lines of
Code: [Select]
if [[ $a -ne "" ]]; then
You just need a unique process name per DE.

Could get a bit long winded if you covered all DE :)

:Edit:  This can be done more elegantly obviously, stuffed full of cold, so am thinking through a bucket of custard at the moment!!


ah ok, sorry I misunderstood. Yes, this should work, let's see what Mbantz will say, he's got lot's to read now  ;)
regards,
-p.

Offline gseaman

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 3881
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #41 on: December 05, 2010, 12:30:21 PM »
It looks like to me that all of Tex's task- packages set $DESKTOP_SESSION, but some of the individual iso's do not. Even though another short term solution is necessary, shouldn't all future isos include setting the initial $DESKTOP_SESSION variable?

Galen

Offline MBantz

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1318
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #42 on: December 05, 2010, 12:31:27 PM »
Thanks for all the replys! Great thoughts and ideas!

Xircon's idea of using pidof is fine if there is a unique process that can identify each DE. For security, it can easily be tampered with by starting a process in kde with the pid name that identifies lxde. But for now it is perhaps sufficient just to get the right DE commands sent away in a script,

If we can get the entire collection of pid names for each DE this would be great. I can see from the discussion so far that we have:

Afterstep: afterstep
Gnome: gnome-session

then we just need openbox, xfce, lxde and kde covered (have I missed one?),

cheers,
MBantz


Offline gseaman

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 3881
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #43 on: December 05, 2010, 12:33:23 PM »
kde = kwin

Galen

Offline xircon

  • Jr. Member
  • **
  • Posts: 11
Re: Why is it so hard to write a gui script for multiple DE?
« Reply #44 on: December 05, 2010, 01:16:52 PM »
openbox = openbox
LXDE = lxsession