[Portland-bugs] [Bug 37899] Factor out scripts' detectDE as xdg-detect-de? ["PATCH"]

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Thu Mar 7 11:00:23 PST 2013


https://bugs.freedesktop.org/show_bug.cgi?id=37899

--- Comment #5 from Antonielly <worldwidetrash at gmail.com> ---
Turn detectDE() into a separate utility

Most applications in xdg-utils need to execute the same piece of code,
currently named detectDE(), to detect the Desktop Environment (DE) for the
current user session. When detectDE() needs to evolve (for instance, to know
how to detect a new DE), it is necessary to change all the applications that
have implemented it.

If we modularize detectDE() into a separate application, the current xdg-utils
tools will still be able to correctly detect the Desktop Environment for the
current user session. The added benefits are that:

1) the code for DE detection will be kept into a single place

2) the size of the code for the current applications in xdg-utils will get
smaller and better focused on their "core missions"

3) inconsistencies will be removed from the current code base (e.g. compare the
current detectDE() implementations in xdg-open and xdg-settings)

4) applications from projects other than xdg-utils will also be able to benefit
from a consistent way to detect the Desktop Environment, by invoking that
program. This opens the door for them to integrate better their look and feel
to each DE, based on runtime detection, and also to provide additional
DE-specific features.

Suggested name for the tool:
xdg-env

Rationale: the "d" in "xdg" means "Desktop". "env" means Environment.

The proposed code for xdg-env is the following:
-------
#!/bin/bash
if [ x"$KDE_FULL_SESSION" = x"true" ]; then echo kde;
elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then echo gnome;
elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus
org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/null
2>&1` ; then echo gnome;
elif [ x"$MATE_DESKTOP_SESSION_ID" != x"" ]; then echo mate;
elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus
org.freedesktop.DBus.GetNameOwner string:org.mate.SessionManager > /dev/null
2>&1`; then echo mate;
elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null
2>&1; then echo xfce;
elif [ x"$DESKTOP_SESSION" = x"LXDE" ]; then echo lxde;
elif [ x"$XDG_CURRENT_DESKTOP" = x"LXDE" ]; then echo lxde;
else echo ""
fi
-------

After including the xdg-env application in xdg-utils, the following changes
will have to be performed for each xdg-utils application (such as xdg-open and
xdg-email):

1) remove the detectDE() function

2) globally replace the line
detectDE
by
DE=`xdg-env`

3) test the application

Migration of the code in xdg-utils can be done piecemeal, application by
application, after xdg-env is made available as an external program.
Refactoring a given application would not affect other xdg-utils programs.

Somewhat related bug reports:
https://bugs.freedesktop.org/show_bug.cgi?id=45604
https://bugs.freedesktop.org/show_bug.cgi?id=23123

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/portland-bugs/attachments/20130307/5dfc50d6/attachment-0001.html>


More information about the Portland-bugs mailing list