nixos/x11: start session with dbus-launch

This is needed by most window managers. Desktop environments
usually launch dbus-launch if a session hasn't been started yet
so this shouldn't hurt. The worst it can happen is that one
dbus session will be unused in case it's started twice.

The GDM change is backported from recent gdm.
This commit is contained in:
Luca Bruno 2015-06-22 16:08:29 +00:00
parent 7907a8bcba
commit f00440fac5
4 changed files with 35 additions and 2 deletions

View File

@ -50,6 +50,12 @@ let
exec > ~/.xsession-errors 2>&1
''}
${optionalString cfg.startDbusSession ''
if test -z "$DBUS_SESSION_BUS_ADDRESS"; then
exec ${pkgs.dbus.tools}/bin/dbus-launch --exit-with-session "$0" "$sessionType"
fi
''}
${optionalString cfg.displayManager.desktopManagerHandlesLidAndPower ''
# Stop systemd from handling the power button and lid switch,
# since presumably the desktop environment will handle these.

View File

@ -238,6 +238,14 @@ in
'';
};
startDbusSession = mkOption {
type = types.bool;
default = true;
description = ''
Whether to start a new DBus session when you log in with dbus-launch.
'';
};
layout = mkOption {
type = types.str;
default = "us";

View File

@ -27,11 +27,10 @@ stdenv.mkDerivation rec {
preBuild = ''
substituteInPlace daemon/gdm-simple-slave.c --replace 'BINDIR "/gnome-session' '"${gnome_session}/bin/gnome-session'
substituteInPlace daemon/gdm-launch-environment.c --replace 'BINDIR "/dbus-launch' '"${dbus.tools}/bin/dbus-launch'
'';
# Disable Access Control because our X does not support FamilyServerInterpreted yet
patches = [ ./xserver_path.patch ./sessions_dir.patch ./disable_x_access_control.patch ];
patches = [ ./xserver_path.patch ./sessions_dir.patch ./disable_x_access_control.patch ./no-dbus-launch.patch ];
meta = with stdenv.lib; {
homepage = https://wiki.gnome.org/Projects/GDM;

View File

@ -0,0 +1,20 @@
--- a/daemon/gdm-launch-environment.c 2015-06-22 15:11:07.277474398 +0000
+++ b/daemon/gdm-launch-environment.c 2015-06-22 15:12:31.301157665 +0000
@@ -48,8 +48,6 @@
#include "gdm-session-enum-types.h"
#include "gdm-launch-environment.h"
-#define DBUS_LAUNCH_COMMAND BINDIR "/dbus-launch --exit-with-session"
-
extern char **environ;
#define GDM_LAUNCH_ENVIRONMENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_LAUNCH_ENVIRONMENT, GdmLaunchEnvironmentPrivate))
@@ -512,7 +510,7 @@
gdm_session_select_program (launch_environment->priv->session, launch_environment->priv->command);
} else {
/* wrap it in dbus-launch */
- char *command = g_strdup_printf ("%s %s", DBUS_LAUNCH_COMMAND, launch_environment->priv->command);
+ char *command = g_strdup (launch_environment->priv->command);
gdm_session_select_program (launch_environment->priv->session, command);
g_free (command);