Morten Nilsen wrote:
Phuah Yee Keat wrote:
Hi,
Yeah, there's no attachments to this email, because I have a 74k
tar.gz file and a 10k .patch file. Should I sent to this list and
flood everybody?
if you can, put the file on a web-server and link it :)
I don't really care, but I suspect other might..
Here you go:
http://www.geocities.com/kiwlm/entrance_xsession_additional.tar.gz
(with whatever bandwidth limit geocities have)
this should be untarred under e17/entrance
1. I have copied the .desktop files from kdm verbatim, and install them
under PACKAGE_DATA_DIR
2. Entrance will now only have a configuration to where to look for
those .desktop files, currently they are stored in a comma separated
path list as '/entrance/sessions/dir'. Being a comma separated value
makes updates to this value harder though, maybe considering
'/entrance/sessions/dir/1', '/entrance/sessions/dir/2'?
3. I have added some defaults (from my own consensus) and also the
location that enlightenment would install its enlightenment.desktop if
enlightenment is using the same --prefix as entrance is. I have found
nothing from google about where these XSession .desktop files should
reside, Application .desktop files should go into
/usr/share/applications though...
4. Entrance would try to look for the executable as specified in TryExec
in the desktop file, in the PATH environment variable, as KDM would have
done it.
5. Since KDM's .desktop files does not have "Icon" parameters, none of
the entries have default Icons, so I made an addition to check if
entrance have the icon files installed, kde.png, enlightenment.png,
gnome.png...
6. Now that the sessions are auto determined, I explicitely added a
"Default" session so that Entrance would go thru Xsession.
7. I have removed all of session/%d/xxx stuffs from build_config.sh.in
and the entrance_config.c.
8. I have only tested compile on my slackware box. No idea whether these
would compile under Fedora/Mandrake/Debian/FreeBSD.
Feedback welcomed. :)
Cheers,
Phuah Yee Keat
? entrance_xprog.patch
? entrance_xprog2.patch
? entrance_xsession.patch
? data/sessions
? doc/html
? doc/latex
? doc/man
? src/client/desktop_entry.c
? src/client/desktop_entry.h
? src/client/find_command.c
? src/client/find_command.h
Index: configure.in
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entrance/configure.in,v
retrieving revision 1.45
diff -u -r1.45 configure.in
--- configure.in 13 Oct 2005 06:06:32 -0000 1.45
+++ configure.in 16 Dec 2005 03:44:59 -0000
@@ -17,6 +17,7 @@
AC_EXPAND_DIR(PACKAGE_DATA_DIR, "$datadir/${PACKAGE}")
AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "$PACKAGE_DATA_DIR", [Shared data
directory])
+AC_SUBST(PACKAGE_DATA_DIR)
AC_EXPAND_DIR(PACKAGE_BIN_DIR, "$bindir")
AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "$PACKAGE_BIN_DIR", [Location of binaries])
@@ -177,6 +178,7 @@
data/themes/taillights/programs/Makefile
data/themes/taillights/images/Makefile
data/themes/taillights/fonts/Makefile
+data/sessions/Makefile
debian/changelog
])
Index: data/Makefile.am
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entrance/data/Makefile.am,v
retrieving revision 1.3
diff -u -r1.3 Makefile.am
--- data/Makefile.am 22 Oct 2003 11:29:59 -0000 1.3
+++ data/Makefile.am 16 Dec 2005 03:44:59 -0000
@@ -1,2 +1,2 @@
-SUBDIRS = config images themes fonts users
+SUBDIRS = config images themes fonts users sessions
Index: data/config/build_config.sh.in
===================================================================
RCS file:
/cvsroot/enlightenment/e17/apps/entrance/data/config/build_config.sh.in,v
retrieving revision 1.17
diff -u -r1.17 build_config.sh.in
--- data/config/build_config.sh.in 10 Dec 2005 03:43:33 -0000 1.17
+++ data/config/build_config.sh.in 16 Dec 2005 03:44:59 -0000
@@ -19,28 +19,7 @@
#ecore_config -c $DB -k /entrance/fonts/1/-s -s
"/usr/X11R6/lib/X11/fonts/Truetype/"
ecore_config -c $DB -k /entrance/greeting/before -s "Welcome to"
ecore_config -c $DB -k /entrance/greeting/after -s ""
-ecore_config -c $DB -k /entrance/session/count -i 7
-ecore_config -c $DB -k /entrance/session/0/session -s "default"
-ecore_config -c $DB -k /entrance/session/0/title -s "Default"
-ecore_config -c $DB -k /entrance/session/0/icon -s "default.png"
-ecore_config -c $DB -k /entrance/session/1/icon -s "enlightenment.png"
-ecore_config -c $DB -k /entrance/session/1/title -s "E17"
-ecore_config -c $DB -k /entrance/session/1/session -s
"@prefix@/bin/enlightenment"
-ecore_config -c $DB -k /entrance/session/2/session -s "kde"
-ecore_config -c $DB -k /entrance/session/2/title -s "KDE"
-ecore_config -c $DB -k /entrance/session/2/icon -s "kde.png"
-ecore_config -c $DB -k /entrance/session/3/session -s "gnome"
-ecore_config -c $DB -k /entrance/session/3/title -s "Gnome"
-ecore_config -c $DB -k /entrance/session/3/icon -s "gnome.png"
-ecore_config -c $DB -k /entrance/session/4/session -s "Enlightenment"
-ecore_config -c $DB -k /entrance/session/4/title -s "E16"
-ecore_config -c $DB -k /entrance/session/4/icon -s "enlightenment.png"
-ecore_config -c $DB -k /entrance/session/5/session -s "xfce"
-ecore_config -c $DB -k /entrance/session/5/title -s "XFce"
-ecore_config -c $DB -k /entrance/session/5/icon -s "xfce.png"
-ecore_config -c $DB -k /entrance/session/6/session -s "failsafe"
-ecore_config -c $DB -k /entrance/session/6/title -s "Failsafe"
-ecore_config -c $DB -k /entrance/session/6/icon -s "failsafe.png"
+ecore_config -c $DB -k /entrance/sessions/dir -s
"/etc/X11/sessions,/usr/share/xsessions,/usr/local/share/xsessions,@PACKAGE_DATA_DIR@/sessions,@prefix@/share/xsessions"
ecore_config -c $DB -k /entrance/system/reboot -i 1
ecore_config -c $DB -k /entrance/system/halt -i 1
ecore_config -c $DB -k /entrance/user/remember -i 1
Index: src/client/Makefile.am
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entrance/src/client/Makefile.am,v
retrieving revision 1.18
diff -u -r1.18 Makefile.am
--- src/client/Makefile.am 5 Sep 2005 16:55:50 -0000 1.18
+++ src/client/Makefile.am 16 Dec 2005 03:45:02 -0000
@@ -13,6 +13,8 @@
entrance_x_session.c entrance_x_session.h \
entrance_ipc.c entrance_ipc.h \
entrance_smart.c entrance_smart.h \
+ desktop_entry.c desktop_entry.h \
+ find_command.c find_command.h \
util.c util.h \
entrance.h main.c
@@ -26,7 +28,8 @@
entrance_edit_SOURCES = \
entrance_edit.c \
- entrance_config.c entrance_user.c \
+ entrance_config.c desktop_entry.c find_command.c \
+ entrance_user.c \
util.c entrance_x_session.c entrance_smart.c
entrance_edit_LDADD = @EDJE_LIBS@ @ECORE_LIBS@ @EVAS_LIBS@ \
@ESMART_LIBS@ -lesmart_container -lesmart_text_entry
Index: src/client/entrance_config.c
===================================================================
RCS file:
/cvsroot/enlightenment/e17/apps/entrance/src/client/entrance_config.c,v
retrieving revision 1.31
diff -u -r1.31 entrance_config.c
--- src/client/entrance_config.c 7 Nov 2005 18:10:41 -0000 1.31
+++ src/client/entrance_config.c 16 Dec 2005 03:45:03 -0000
@@ -1,9 +1,14 @@
#include <Ecore_Config.h>
+#include <dirent.h>
+#include <ctype.h>
+
#include "entrance.h"
#include "entrance_config.h"
#include "entrance_user.h"
#include "entrance_x_session.h"
+#include "desktop_entry.h"
+#include "find_command.h"
/**
@file entrance_config.c
@@ -52,15 +57,107 @@
ecore_config_int_default("/entrance/system/reboot", 1);
ecore_config_int_default("/entrance/system/halt", 1);
- ecore_config_int_default("/entrance/session/count", 1);
- ecore_config_string_default("/entrance/session/0/session", "default");
- ecore_config_string_default("/entrance/session/0/title", "Default");
- ecore_config_string_default("/entrance/session/0/icon", "default.png");
+ ecore_config_string_default("/entrance/sessions/dir", PACKAGE_DATA_DIR
"/sessions");
ecore_config_int_default("/entrance/auth", 1);
}
/**
+ * desktop_filter - a filter to scandir, to only accepts .desktop files
+ * @param d dirent structure to filter
+ */
+static int
+desktop_filter(const struct dirent *d)
+{
+ if (strstr(d->d_name, ".desktop")==NULL) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
+/**
+ * tolower_str - converts the string to lower case, in place
+ * @param str String to convert
+ */
+static void
+tolower_str(char *str)
+{
+ size_t i;
+ size_t len = strlen(str);
+ for (i=0;i<len;++i) {
+ str[i] = tolower(str[i]);
+ }
+}
+
+/**
+ * entrance_config_load_sessions - load the sessions from the
+ * sessions/dir as configured
+ * @param e Valid Entrance_Config struct
+ */
+static void
+entrance_config_load_sessions(Entrance_Config *e)
+{
+ char *sessions_dir = NULL;
+ char *session_path = NULL;
+ char fullpath[1024] = {0};
+ struct dirent **desktop_files = NULL;
+ int i, n;
+ Desktop_Entry *d = NULL;
+ Entrance_X_Session *exs = NULL;
+
+ /* we must have a default */
+ if ((exs = entrance_x_session_new("Default", "default.png", "default"))) {
+ e->sessions.keys = evas_list_append(e->sessions.keys, "Default");
+ e->sessions.hash = evas_hash_add(e->sessions.hash, "Default", exs);
+ }
+
+ sessions_dir = strdup(ecore_config_string_get("/entrance/sessions/dir"));
+
+ session_path = strtok(sessions_dir, ",");
+
+ while (session_path) {
+ n = scandir(session_path, &desktop_files, desktop_filter, NULL);
+ if (n>0) {
+ for (i=0;i<n;i++) {
+ snprintf(fullpath, sizeof(fullpath), "%s/%s",
+ session_path, desktop_files[i]->d_name);
+ d = desktop_entry_load(fullpath);
+ if (d && strcmp(d->type, TYPE_XSESSION)==0) {
+ if (d->tryexec==NULL) {
+ d->tryexec = d->exec;
+ }
+ if (d->tryexec) {
+ char *tryexec_fullpath = find_command_in_path(d->tryexec);
+ if (tryexec_fullpath) {
+ if (d->icon==NULL) {
+ /* see if there's an icon from entrance */
+ char myicon[PATH_MAX];
+ snprintf(myicon, PATH_MAX, "%s.png", d->name);
+ tolower_str(myicon);
+ d->icon = strdup(myicon);
+ }
+ if ((exs = entrance_x_session_new(d->name, d->icon,
d->exec))) {
+ e->sessions.keys = evas_list_append(
+ e->sessions.keys, d->name);
+ e->sessions.hash = evas_hash_add(
+ e->sessions.hash, exs->name, exs);
+ }
+ free(tryexec_fullpath);
+ }
+ }
+ }
+ free(desktop_files[i]);
+ }
+ free(desktop_files);
+ }
+ session_path = strtok(NULL, ",");
+ }
+
+ free(sessions_dir);
+}
+
+/**
* entrance_config_populate - populate the Entrance_Config struct with
* the data from ecore_config
* @param e Valid Entrance_Config struct
@@ -73,10 +170,7 @@
char *icon = NULL;
char *session = NULL;
- char *title = NULL;
- Entrance_X_Session *exs;
-
- int i, num_session, num_user;
+ int i, num_user;
char buf[PATH_MAX];
if (!e) return;
@@ -132,23 +226,7 @@
}
}
- num_session = ecore_config_int_get("/entrance/session/count");
- for (i = 0; i < num_session; i++)
- {
- snprintf(buf, PATH_MAX, "/entrance/session/%d/title", i);
- title = ecore_config_string_get(buf);
- snprintf(buf, PATH_MAX, "/entrance/session/%d/session", i);
- session = ecore_config_string_get(buf);
- snprintf(buf, PATH_MAX, "/entrance/session/%d/icon", i);
- icon = ecore_config_string_get(buf);
-
- if ((exs = entrance_x_session_new(title, icon, session)))
- {
- e->sessions.keys = evas_list_append(e->sessions.keys, title);
- e->sessions.hash =
- evas_hash_add(e->sessions.hash, exs->name, exs);
- }
- }
+ entrance_config_load_sessions(e);
#if 0
if (!e_db_int_get(db, "/entrance/xinerama/screens/w", &(e->screens.w)))