Support recognizing current DE with $XDG_CURRENT_DESKTOP and make new released.
authorHong Jen Yee (PCMan) <pcman.tw@gmail.com>
Thu, 10 Dec 2009 18:51:29 +0000 (18:51 +0000)
committerHong Jen Yee (PCMan) <pcman.tw@gmail.com>
Thu, 10 Dec 2009 18:51:29 +0000 (18:51 +0000)
configure.ac
lxsession/autostart.c
lxsession/lxsession.c

index 08a9b7f..c38a8f5 100644 (file)
@@ -1,6 +1,6 @@
 AC_PREREQ([2.57])
-AC_INIT(lxsession,[0.4.0], [],lxsession)
-AM_INIT_AUTOMAKE([dist-bzip2])
+AC_INIT(lxsession,[0.4.1], [],lxsession)
+AM_INIT_AUTOMAKE()
 AC_PROG_INTLTOOL(, [no-xml])
 AM_MAINTAINER_MODE
 
index 4b353df..b7cb42e 100644 (file)
@@ -24,7 +24,7 @@
 #include <string.h>
 
 static const char DesktopEntry[] = "Desktop Entry";
-extern const char* session_name;
+extern const char* de_name; /* defined in lxsession.c */
 
 #if 0
 /*
@@ -189,7 +189,7 @@ static void launch_autostart_file( const char* desktop_id, const char* desktop_f
             for( i = 0; i < n; ++i )
             {
                 /* Only start this program if we are in the "OnlyShowIn" list */
-                if( 0 == strcmp( session_name, only_show_in[ i ] ) )
+                if( 0 == strcmp( de_name, only_show_in[ i ] ) )
                     break;
             }
             if( i >= n )    /* our session name is not found in the list */
@@ -210,7 +210,7 @@ static void launch_autostart_file( const char* desktop_id, const char* desktop_f
                                for( i = 0; i < n; ++i )
                                {
                                        /* Only start this program if we are in the "OnlyShowIn" list */
-                                       if( 0 == strcmp( session_name, not_show_in[ i ] ) )
+                                       if( 0 == strcmp( de_name, not_show_in[ i ] ) )
                                                break;
                                }
                                if( i < n )    /* our session name is found in the "NotShowIn" list */
@@ -260,7 +260,7 @@ static void launch_autostart_file( const char* desktop_id, const char* desktop_f
     }
 }
 
-static void get_autostart_files_in_dir( GHashTable* hash, const char* session_name, const char* base_dir )
+static void get_autostart_files_in_dir( GHashTable* hash, const char* de_name, const char* base_dir )
 {
     char* dir_path = g_build_filename( base_dir, "autostart", NULL );
     GDir* dir = g_dir_open( dir_path, 0, NULL );
@@ -280,7 +280,7 @@ static void get_autostart_files_in_dir( GHashTable* hash, const char* session_na
     g_free( dir_path );
 }
 
-void handle_autostart( const char* session_name )
+void handle_autostart( const char* de_name )
 {
     const char* const *dirs = g_get_system_config_dirs();
     const char* const *dir;
@@ -288,10 +288,10 @@ void handle_autostart( const char* session_name )
 
     /* get system-wide autostart files */
     for( dir = dirs; *dir; ++dir )
-        get_autostart_files_in_dir( hash, session_name, *dir );
+        get_autostart_files_in_dir( hash, de_name, *dir );
 
     /* get user-specific autostart files */
-    get_autostart_files_in_dir( hash, session_name, g_get_user_config_dir() );
+    get_autostart_files_in_dir( hash, de_name, g_get_user_config_dir() );
 
     if( g_hash_table_size( hash ) > 0 )
     {
index 46069ac..3280580 100644 (file)
@@ -55,7 +55,7 @@ static char prog_name[]="lxsession";
 static char autostart_filename[]="autostart";
 
 const char *session_name = NULL;
-
+const char* de_name = NULL;
 
 static GPid run_app( const char* cmd );
 static void run_guarded_app( const char* cmd );
@@ -238,6 +238,10 @@ static void parse_options(int argc, char** argv)
             case 'n': /* disable xsettings daemon */
                                no_settings = TRUE;
                 continue;
+            case 'e': /* DE name */
+                if ( ++i >= argc ) goto usage;
+                de_name = argv[i];
+                continue;
             case 'r':
                                reload_settings = TRUE;
                                continue;
@@ -250,8 +254,9 @@ static void parse_options(int argc, char** argv)
 usage:
         fprintf ( stderr,
                   "Usage:  lxsession [OPTIONS...]\n"
-                                 "\t-d name\tspecify name of display (optional)\n"
-                                 "\t-s name\tspecify name of the desktop session\n"
+                                 "\t-d NAME\tspecify name of display (optional)\n"
+                                 "\t-s NAME\tspecify name of the desktop session profile\n"
+                  "\t-e NAME\tspecify name of DE, such as LXDE, GNOME, or XFCE.\n"
                                  "\t-r\t reload configurations (for Xsettings daemon)\n"
                                  "\t-n\t disable Xsettings daemon support\n" );
         exit(1);
@@ -302,11 +307,11 @@ int main(int argc, char** argv)
 
     if ( G_UNLIKELY(!session_name) )
         session_name = "LXDE";
-
     g_setenv( "DESKTOP_SESSION", session_name, TRUE );
 
-    /* FIXME: setup locales: LC_ALL, LANG, LANGUAGE?
-        * Is this needed? */
+    if ( G_UNLIKELY(!de_name) )
+        session_name = session_name;
+    g_setenv( "XDG_CURRENT_DESKTOP", de_name, TRUE );
 
     /* FIXME: load environment variables? */