Policykit Not Initialized in Custom Xsession via LightDM – Fix Guide

11.10gnomegnome-sessionlightdmpolicykit

I'm running a fully updated Ubuntu 11.10 install and I've been using LightDM to launch a "User Defined Session" which executes the .xsession script in my home folder. The script that I have written runs perfectly with the exception that I can not mount partitions in nautilus or access the User Accounts entry of System Settings. I presume this is a problem with policykit not starting correctly due to a problem with my script. Any help would be appreciated.

My .xsession:

#! /bin/bash
ck-launch-session dbus-launch compiz &
ck-launch-session dbus-launch gnome-settings-daemon &
ck-launch-session dbus-launch docky &
ck-launch-session dbus-launch synapse

Best Answer

The solution to this problem is not a .xsession script, but a custom tailored gnome session, just like unity, unity2d, gnome-classic are all varieties of the gnome desktop.

The Session file

Place this under /usr/share/gnome-session/sessions and name it docky.session

[GNOME Session]
Name=Neither Ubuntu nor Gnome
Required=windowmanager;panel;filemanager;
Required-windowmanager=compiz
Required-panel=docky
Required-filemanager=nautilus
DefaultApps=gnome-settings-daemon;synapse;

The xsession file

Place this under /usr/share/xsessions and name it docky.desktop

[Desktop Entry]
Name=Docky
Comment=This session logs you into Ubuntu
Exec=gnome-session --session=docky
TryExec=gnome-session
Icon=
Type=Application
X-Ubuntu-Gettext-Domain=gnome-session-2.0

It is just too much work to figure out which freedesktop stuff like DBus, policykit, gvfs has to be started in which order, just let the gnome-session do the heavy lifting and concentrate on what is considered essential.

EDIT: This works with 11.04 and gdm, but the session file format has changed in 11.10, so docky.session needs to look like:

[GNOME Session]
Name=Docky
RequiredComponents=gnome-settings-daemon;
RequiredProviders=windowmanager;panel;launcher;
DefaultProvider-windowmanager=compiz
DefaultProvider-panel=docky
DefaultProvider-launcher=synapse
IsRunnableHelper=/usr/lib/gnome-session/gnome-session-check-accelerated
DesktopName=Docky