$OpenBSD: patch-gnome-session_main_c,v 1.8 2012/01/02 16:06:50 ajacoutot Exp $

Two OpenBSD specific changes:
* set default openfiles soft limit to 512 (if current value is lower)
* set XDG_MENU_PREFIX so that menu is created from
  SYSCONFDIR/xdg/menus/gnome-applications.menu

--- gnome-session/main.c.orig	Thu Sep  8 00:55:51 2011
+++ gnome-session/main.c	Mon Jan  2 16:42:54 2012
@@ -28,6 +28,12 @@
 #include <unistd.h>
 #include <errno.h>
 
+#ifdef __OpenBSD__
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#endif
+
 #include <glib/gi18n.h>
 #include <glib.h>
 #include <gtk/gtk.h>
@@ -264,6 +270,9 @@ require_dbus_session (int      argc,
 int
 main (int argc, char **argv)
 {
+#ifdef __OpenBSD__
+        struct rlimit rl;
+#endif
         struct sigaction  sa;
         GError           *error;
         char             *display_str;
@@ -333,6 +342,25 @@ main (int argc, char **argv)
          * detect if GNOME is running. We keep this for compatibility reasons.
          */
         gsm_util_setenv ("GNOME_DESKTOP_SESSION_ID", "this-is-deprecated");
+
+        /* Set default menu to gnome-applications.menu if XDG_MENU_PREFIX
+         * is not set.
+         */
+        if (!g_getenv ("XDG_MENU_PREFIX")) {
+                gsm_util_setenv ("XDG_MENU_PREFIX", "gnome-");
+        }
+
+#ifdef __OpenBSD__
+        if (getrlimit (RLIMIT_NOFILE, &rl) == 0) {
+                if (rl.rlim_cur < 512) {
+                        rl.rlim_cur = 512;
+                        if (setrlimit(RLIMIT_NOFILE, &rl) < 0)
+                                g_warning ("Can't increase max open files per process");
+                }
+        } else {
+                g_warning ("Can't get resource limit for open files");
+        }
+#endif
 
         client_store = gsm_store_new ();
 
