Tags: + patch

Attached is patch that fixes this.  Now lxsession first tries to load the
user's autostart (usually ~/.config/lxsession/<NAME>/autostart).  If that
fails walks backwards through the list of system configuration directories and
tries to load an autostart file from each of them, stopping at the first one
that succeeds.  This way later directories take precedence over earlier ones,
and the user configuration takes precedence over the system configuration.

Thanks,
Jö.

-- 
Jorrit (Jö) Fahlke, Interdisciplinary Center for Scientific Computing,
Heidelberg University, Im Neuenheimer Feld 368, D-69120 Heidelberg
Tel: +49 6221 54 8890 Fax: +49 6221 54 8884

In the beginning the Universe was created.  This has made a lot of
people very angry and been widely regarded as a bad move.
-- Douglas Adams
Description: Make the user's autostart superseed the systems autostart
 The old behaviour was that later candidates in the list of autostart files
 superseeded earlier one, which leaves the user no possibility to disable
 system autostart entries.
Author: Jö Fahlke <jor...@jorrit.de>
Bug-Debian: http://bugs.debian.org/642336
Last-Update: 2011-09-21

--- lxsession-0.4.4.orig/lxsession/lxsession.c
+++ lxsession-0.4.4/lxsession/lxsession.c
@@ -152,7 +152,7 @@ GPid run_app( const char* cmd, gboolean
     return pid;
 }
 
-static void load_default_apps( const char* filename )
+static gboolean load_default_apps( const char* filename )
 {
     char buf[1024];
     int len;
@@ -179,7 +179,10 @@ static void load_default_apps( const cha
             }
         }
         fclose( file );
+        return TRUE;
     }
+    else
+        return FALSE;
 }
 
 /*
@@ -193,22 +196,31 @@ void start_session()
     const gchar* const *dir;
     GKeyFile* kf = g_key_file_new();
     char* filename;
+    gboolean autostart_done;
 
     /* run window manager first */
     if( G_LIKELY( window_manager ) )
         run_app( window_manager, TRUE );
 
-    /* load system-wide default apps */
-    for( dir = dirs; *dir; ++dir )
-    {
-        filename = g_build_filename( *dir, prog_name, session_name, autostart_filename, NULL );
-        load_default_apps( filename );
-        g_free( filename );
-    }
     /* load user-specific default apps */
     filename = g_build_filename( g_get_user_config_dir(), prog_name, session_name, autostart_filename, NULL );
-    load_default_apps( filename );
+    autostart_done = load_default_apps( filename );
     g_free( filename );
+    if ( ! autostart_done )
+    {
+        /* load system-wide default apps */
+        for( dir = dirs; *dir; ++dir )
+            /* do nothing */;
+        /* go through the list of system configuration directories backwards
+           since the last existing files superseeds all the others */
+        while( ! autostart_done && dir != dirs )
+        {
+            --dir;
+            filename = g_build_filename( *dir, prog_name, session_name, autostart_filename, NULL );
+            autostart_done = load_default_apps( filename );
+            g_free( filename );
+        }
+    }
 
     /* Support autostart spec of freedesktop.org */
     xdg_autostart( session_name );

Attachment: signature.asc
Description: Digital signature

Reply via email to