Author Topic: Script: How to tell the new DE's apart?  (Read 959 times)

Offline MBantz

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1317
Script: How to tell the new DE's apart?
« on: April 21, 2010, 05:17:30 AM »
Hi all,

I am currently fixing up a script I use for Arduino and mythTV to make sure a user is in the correct group at startup - and with the new DE's - I need to amend it to recognize all the new DE's.

Is this true with the new DE's?

A)
KDE is identified by:
    if [ x"$KDE_FULL_SESSION" = x"true" ]; then
   DE=kde;
    fi

B)
GNOME is identified by:
     if [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then
   DE=gnome;
     fi

C)
XFCE is identified by:
     if xprop -root _DT_SAVE_MODE | grep ' = \"xfce4\"$' >/dev/null 2>&1; then
   DE=xfce;
     fi


How do I identify (A, B or C):
LXDE
OpenBox
e17
Zen-Mini
Minime


This is the current code I'm currently fixing, just fyi:
Code: [Select]
find_session()
{
    if [ x"$KDE_FULL_SESSION" = x"true" ]; then
DE=kde;
DIALOG=`which kdialog`;
DIALOG_TYPE=kdialog;
        SU=`which kdesu`
SU_TYPE=kdesu
    elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then
DE=gnome;
DIALOG=`which zenity`;
DIALOG_TYPE=zenity;
        SU=`which gksu`
SU_TYPE=gksu
    elif xprop -root _DT_SAVE_MODE | grep ' = \"xfce4\"$' >/dev/null 2>&1; then
DE=xfce;
DIALOG=`which zenity`;
DIALOG_TYPE=zenity;
        SU=`which gksu`
SU_TYPE=gksu
    fi
}

thanks,
MBantz

Offline pinoc

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2847
    • other projects...
Re: Script: How to tell the new DE's apart?
« Reply #1 on: April 21, 2010, 05:57:58 AM »
Hi MBantz,

this is interesting stuff I was after when doing addlocale but then it depends what you are after. If all you need to distinguish is gksu/kdesu and a way for dialog messages then zenity is good for any DE and a simple test for kdesu (`which kdesu`) should be sufficient, either kdesu exist, or if not then it must be gksu. But maybe you want to do more sophisticated things later on. In any case, I'd be interested as well in finding a good way to distinguish between the different DE's, not only if they are installed in the system, but more importantly, which DE is currently running.
best,
-p.

Offline MBantz

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1317
Re: Script: How to tell the new DE's apart?
« Reply #2 on: April 21, 2010, 06:52:32 AM »
Thanks for your answer pinoc :-)

It's LXDE I cannot recognize right now, it falls 'between chairs' in the current logic, and hence does not add the user to the necessary group.

Additionally, it appears that each of the DE's need special handling when exiting a session - and I assume other small quirks are needed for every DE over time.

Code: [Select]
if [ "$DE" = "gnome" ]; then
gnome-session-save --kill
elif [ "$DE" = "kde" ]; then
dcop ksmserver ksmserver logout 0 0 0
elif [ "$DE" = "xfce" ]; then
xfce4-session-logout

Offline MBantz

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1317
Re: Script: How to tell the new DE's apart?
« Reply #3 on: April 21, 2010, 04:26:20 PM »
some clues here:

What Linux is installed:
[mbz@localhost ~]$ cat /etc/issue
ZEN-mini release 2010 (PCLinuxOS) for i586

List of DE and their order:
[mbz@localhost dm.d]$ /usr/sbin/chksession -L
GNOME=02 drak3d=29
(though GNOME is probably the setting for xfce and lxde, and xfce has a special exit session command - so this is not informative enough.)


It's still interesting to know what DE is actually running, if I for instance have LXDE, XFCE and KDE installed.

Anyone?
« Last Edit: April 21, 2010, 04:33:58 PM by MBantz »

Offline travisN000

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1758
Re: Script: How to tell the new DE's apart?
« Reply #4 on: April 22, 2010, 08:16:44 PM »
you can get the default DE at boot with:
Code: [Select]
grep "DESKTOP=" /etc/sysconfig/desktop | cut -d= -f2

Offline pinoc

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2847
    • other projects...
Re: Script: How to tell the new DE's apart?
« Reply #5 on: April 23, 2010, 12:18:22 AM »
you can get the default DE at boot with:
Code: [Select]
grep "DESKTOP=" /etc/sysconfig/desktop | cut -d= -f2

yes, that will provide the default DE of the system. However, this may not be the actual DE in use, i.e., if the user selects another non-default DE to play with.  :(  The challenge remains to determine the effectively running DE.
If I remember correctly, one could detect a running e17 DE by test-running the command
Code: [Select]
enlightenment_remotewhich will only work if e17 is actually running; don't have a multi-DE install right now to verify that it was exactly this command but I'm sure it was one of the "enlightenment" commands.
regards,
-p.

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: Script: How to tell the new DE's apart?
« Reply #6 on: April 23, 2010, 05:13:48 AM »
My present install is multi DE, so here are the results of some of the commands posted ....  may be of some help

Code: [Select]
$ cat /etc/issue
PCLinuxOS release 2010 (PCLinuxOS) for i586
Kernel 2.6.27.31.tex5 on an i686 / \l

Code: [Select]
$ /usr/sbin/chksession -L
KDE=01 GNOME=02 LXDE=04 Openbox=25 Openbox-KDE=27 Openbox-Gnome=28 drak3d=29

The results using a different DE are not the same for the second command above.

regards.