Index: introduction/welcome/changelog.xml
===================================================================
--- introduction/welcome/changelog.xml	(revision 1c2bec773011cbbd84bad8b02b760355ba52f32b)
+++ introduction/welcome/changelog.xml	(revision eca7a588ace1ac770493bd6c224aa0300450ef34)
@@ -47,4 +47,9 @@
       <para>September 24th, 2015</para>
       <itemizedlist>
+        <listitem>
+          <para>[fernando] - Fix starting X with startx (from xinit) and sddm
+          (with consolekit2 and upowerd) and somwhat related fixes. Fixes
+          <ulink url="&blfs-ticket-root;6972">#6972</ulink>.</para>
+        </listitem>
         <listitem>
           <para>[bdubbs] - Update to KDE Frameworks 5.14. Fixes
Index: kde/core/config.xml
===================================================================
--- kde/core/config.xml	(revision 1c2bec773011cbbd84bad8b02b760355ba52f32b)
+++ kde/core/config.xml	(revision eca7a588ace1ac770493bd6c224aa0300450ef34)
@@ -30,19 +30,48 @@
   <title>Starting KDE4 from the command prompt</title>
 
- <para>To start <application>KDE4</application> from the command prompt, you
- first need to modify your <filename>.xinitrc</filename> file:</para>
+    <para>
+      You can start <application>KDE4</application> from runlevel 3, using
+      <xref linkend="xinit"/>, or from runlevel 5, using a Display Manager,
+      such as <xref linkend="sddm"/>.
+    </para>
 
-<screen><userinput>cat &gt; ~/.xinitrc &lt;&lt; EOF
-<literal># Begin .xinitrc
+    <para>
+      To start <application>KDE4</application> using <xref linkend="xinit"/>,
+      run the following commands:
+    </para>
 
-exec ck-launch-session dbus-launch --exit-with-session startkde
+<screen><userinput>cat &gt; ~/.xinitrc &lt;&lt; "EOF"
+<literal>ck-launch-session dbus-launch --exit-with-session startkde</literal>
+EOF
 
-# End .xinitrc</literal>
-EOF</userinput></screen>
+startx</userinput></screen>
 
-    <note><para>If you are not using <application>ConsoleKit</application>, remove
-    <userinput>ck-launch-session</userinput>.</para></note>
+    <para>
+      The X session starts on the first unused virtual terminal, normally vt7.
+      You can switch to a vtn (n=1, 2, ...) simultaneously pressing the keys
+      Ctrl-Alt-Fn. To switch back to the X session, normally started at vt7,
+      use Ctrl-Alt-F7. If started from vt1 (the usual case), you will see many
+      messages there, including X starting messages, applications automatically
+      started with the session, and eventually, some warning and error
+      messages. You may prefer to redirect those messages to a log file, which
+      not only will keep vt1 uncluttered, but also can be used for debug
+      purposes. This can be done starting X with:
+    </para>
 
-    <para>You can now start KDE4 using the <command>startx</command> command.</para>
+    <screen><userinput>startx &amp;&gt; ~/.x-session-errors</userinput></screen>
+
+    <para>
+      You may wish to drop consolekit and/or dbus-launch, e.g., just using
+      startlxde in .~/.xinitrc, but some functionalities such as mount/umount
+      file systems from a file manager will not be possible, or the reboot
+      option will be absent or not functioning, between other problems.
+    </para>
+
+    <para>
+      Because X is (normally) on vt7, when you shutdown the vt is switched back
+      to that one where the command starting it was executed. In this case, if
+      you wish to see the shutdown messages, simultaneously press keys Alt-F7,
+      because normally those messages appear on the vt where X was running.
+    </para>
 
     </sect2>
Index: lxde/desktop/lxde-common.xml
===================================================================
--- lxde/desktop/lxde-common.xml	(revision 1c2bec773011cbbd84bad8b02b760355ba52f32b)
+++ lxde/desktop/lxde-common.xml	(revision eca7a588ace1ac770493bd6c224aa0300450ef34)
@@ -139,4 +139,10 @@
 
     <para>
+      You can start <application>LXDE</application> from runlevel 3, using
+      <xref linkend="xinit"/>, or from runlevel 5, using a Display Manager,
+      such as <xref linkend="sddm"/>.
+    </para>
+
+    <para>
       To start <application>LXDE</application> using <xref linkend="xinit"/>,
       run the following commands:
@@ -144,28 +150,36 @@
 
 <screen><userinput>cat &gt; ~/.xinitrc &lt;&lt; "EOF"
-startlxde
+<literal>ck-launch-session dbus-launch --exit-with-session startlxde</literal>
 EOF
 
 startx</userinput></screen>
 
-  <note>
-    <para>
-      When <xref linkend="consolekit"/> was built, if you did not use the
-      recommended <xref linkend="linux-pam"/> dependency or did not rebuild
-      <xref linkend="shadow"/> with Linux-PAM, ~/.xinitrc should have the
-      entry:
-    </para>
-
-    <screen><userinput>ck-launch-session startlxde</userinput></screen>
-
-    <para>to obtain the appropriate permissions for system functions.</para>
-  
-    <para>
-      To test if ck-launch-session is needed, run
-      <command>ck-list-sessions</command> fropm the command line.  If a session
-      associated with the current tty is present that is both 'active' and
-      'local' then <command>ck-launch-session</command> is not needed.
-    </para>
-  </note>
+    <para>
+      The X session starts on the first unused virtual terminal, normally vt7.
+      You can switch to a vtn (n=1, 2, ...) simultaneously pressing the keys
+      Ctrl-Alt-Fn. To switch back to the X session, normally started at vt7,
+      use Ctrl-Alt-F7. If started from vt1 (the usual case), you will see many
+      messages there, including X starting messages, applications automatically
+      started with the session, and eventually, some warning and error
+      messages. You may prefer to redirect those messages to a log file, which
+      not only will keep vt1 uncluttered, but also can be used for debug
+      purposes. This can be done starting X with:
+    </para>
+
+    <screen><userinput>startx &amp;&gt; ~/.x-session-errors</userinput></screen>
+
+    <para>
+      You may wish to drop consolekit and/or dbus-launch, e.g., just using
+      startlxde in .~/.xinitrc, but some functionalities such as mount/umount
+      file systems from a file manager will not be possible, or the reboot
+      option will be absent or not functioning, between other problems.
+    </para>
+
+    <para>
+      Because X is (normally) on vt7, when you shutdown the vt is switched back
+      to that one where the command starting it was executed. In this case, if
+      you wish to see the shutdown messages, simultaneously press keys Alt-F7,
+      because normally those messages appear on the vt where X was running.
+    </para>
 
   </sect2>
Index: lxqt/desktop/post-install.xml
===================================================================
--- lxqt/desktop/post-install.xml	(revision 1c2bec773011cbbd84bad8b02b760355ba52f32b)
+++ lxqt/desktop/post-install.xml	(revision eca7a588ace1ac770493bd6c224aa0300450ef34)
@@ -85,6 +85,7 @@
 
     <para>
-      If an optional Display Manager have been installed and you wish to use it,
-      skip the following steps.
+      You can start <application>LXQt</application> from runlevel 3, using
+      <xref linkend="xinit"/>, or from runlevel 5, using a Display Manager,
+      such as <xref linkend="sddm"/>.
     </para>
 
@@ -94,10 +95,38 @@
     </para>
 
-<screen><userinput>cat &gt;&gt; ~/.xinitrc &lt;&lt; "EOF"
-ck-launch-session startlxqt
+<screen><userinput>cat &gt; ~/.xinitrc &lt;&lt; "EOF"
+<literal>ck-launch-session dbus-launch --exit-with-session startlxqt</literal>
 EOF
 
 startx</userinput></screen>
 
+    <para>
+      The X session starts on the first unused virtual terminal, normally vt7.
+      You can switch to a vtn (n=1, 2, ...) simultaneously pressing the keys
+      Ctrl-Alt-Fn. To switch back to the X session, normally started at vt7,
+      use Ctrl-Alt-F7. If started from vt1 (the usual case), you will see many
+      messages there, including X starting messages, applications automatically
+      started with the session, and eventually, some warning and error
+      messages. You may prefer to redirect those messages to a log file, which
+      not only will keep vt1 uncluttered, but also can be used for debug
+      purposes. This can be done starting X with:
+    </para>
+
+    <screen><userinput>startx &amp;&gt; ~/.x-session-errors</userinput></screen>
+
+    <para>
+      You may wish to drop consolekit and/or dbus-launch, e.g., just using
+      startlxde in .~/.xinitrc, but some functionalities such as mount/umount
+      file systems from a file manager will not be possible, or the reboot
+      option will be absent or not functioning, between other problems.
+    </para>
+
+    <para>
+      Because X is (normally) on vt7, when you shutdown the vt is switched back
+      to that one where the command starting it was executed. In this case, if
+      you wish to see the shutdown messages, simultaneously press keys Alt-F7,
+      because normally those messages appear on the vt where X was running.
+    </para>
+
   </sect2>
 
Index: postlfs/security/consolekit.xml
===================================================================
--- postlfs/security/consolekit.xml	(revision 1c2bec773011cbbd84bad8b02b760355ba52f32b)
+++ postlfs/security/consolekit.xml	(revision eca7a588ace1ac770493bd6c224aa0300450ef34)
@@ -120,5 +120,7 @@
             --enable-pam-module  \
             --enable-polkit      \
-            --with-systemdsystemunitdir=no &amp;&amp;
+            --with-xinitrc-dir=/etc/X11/app-defaults/xinitrc.d \
+            --docdir=/usr/share/doc/ConsoleKit-&consolekit-version;           \
+            --with-systemdsystemunitdir=no                     &amp;&amp;
 make</userinput></screen>
 
@@ -131,5 +133,7 @@
     </para>
 
-<screen role="root"><userinput>make install</userinput></screen>
+<screen role="root"><userinput>make install &amp;&amp;
+
+mv -v /etc/X11/app-defaults/xinitrc.d/90-consolekit{,.sh}</userinput></screen>
 
   </sect2>
@@ -151,5 +155,5 @@
       <application>ConsoleKit</application> to work correctly with
       <application>PAM</application>. Remove if
-      <application>Linux PAM</application> is 
+      <application>Linux PAM</application> is
       <emphasis role="strong">NOT</emphasis> installed.
     </para>
@@ -157,4 +161,11 @@
     <para>
       <parameter>--enable-polkit</parameter>: Enable PolicyKit support.
+    </para>
+
+    <para>
+      <parameter>--with-xinitrc-dir=/etc/X11/app-defaults/xinitrc.d</parameter>:
+      Fix the localization of the 90-consolekit.sh script. Notice that the
+      script was renamed, after installation, because xinitrc expects script
+      names to have extension <emphasis>.sh</emphasis>.
     </para>
 
@@ -252,9 +263,6 @@
         </seg>
         <seg>
-          /etc/ConsoleKit,
-          /usr/include/ConsoleKit,
-          /usr/lib/ConsoleKit,
-          /usr/share/doc/ConsoleKit and
-          /var/log/ConsoleKit
+          /{etc,usr/{include,lib},var/{log,run}}/ConsoleKit and
+          /usr/share/doc/ConsoleKit-&consolekit-version;
         </seg>
       </seglistitem>
Index: x/dm/sddm.xml
===================================================================
--- x/dm/sddm.xml	(revision 1c2bec773011cbbd84bad8b02b760355ba52f32b)
+++ x/dm/sddm.xml	(revision eca7a588ace1ac770493bd6c224aa0300450ef34)
@@ -122,4 +122,16 @@
 
     <para>
+      First, fix the application to start <command>upowerd</command>,
+      if necessary, and after login, start the session with
+      <command>ck-launch-session</command>:
+    </para>
+
+<screen><userinput>sed -e '/UPOWER_SERVICE)/ s:^://:' \
+    -i src/daemon/PowerManager.cpp &amp;&amp;
+
+sed -e 's/eval exec/&amp; ck-launch-session /' \
+    -i data/scripts/Xsession</userinput></screen>
+
+    <para>
       Install <application>SDDM</application> by running the following
       commands:
@@ -132,4 +144,5 @@
       -DCMAKE_BUILD_TYPE=Release  \
       -DENABLE_JOURNALD=OFF       \
+      -DDBUS_CONFIG_FILENAME=sddm_org.freedesktop.DisplayManager.conf \
       -Wno-dev .. &amp;&amp;
 make</userinput></screen>
@@ -159,4 +172,11 @@
       <parameter>-DENABLE_JOURNALD=OFF</parameter>: This switch is used because
       BLFS does not support <application>systemd</application>.
+    </para>
+
+    <para>
+      <parameter>-DDBUS_CONFIG_FILENAME=sddm_org.freedesktop.DisplayManager.conf</parameter>:
+      This switch is used for safety reason: other DMs already use
+      <filename>org.freedesktop.DisplayManager.conf</filename>. Verify in your
+      system taht this is not the case, if you wish to remove it.
     </para>
 
@@ -186,23 +206,31 @@
       <para>
         This file is not installed with the build instructions, and
-        default values are used by sddm. In order to generate the default
-        <filename>/etc/sddm.conf</filename>, issue, as the <systemitem
-        class="username">root</systemitem> user:
-      </para>
-
-<screen role="root"><userinput>sddm --example-config > /etc/sddm.conf</userinput></screen>
-
-      <para>
-        You need to edit this file, if your system has any unconventional
-        characteristics. For example, if Xorg is installed in /opt, use your
-        preferred editor as the <systemitem class="username">root</systemitem>
-        user to replace the <emphasis>ServerPath</emphasis> and
-        <emphasis>XauthPath</emphasis> default paths by
-        <emphasis>/opt/xorg/bin/</emphasis>. Or, as the <systemitem
+        default values are used by sddm. In order to generate the example
+        <filename>sddm.example.conf</filename>, issue:
+      </para>
+
+<screen><userinput>sddm --example-config > sddm.example.conf</userinput></screen>
+
+      <para>
+        We repeat, this command generates an example config file.  If there is
+        an already previously installed <filename>/etc/sddm.conf</filename>, it
+        will generate a replica. If there is no yet the
+        <filename>/etc/sddm.conf</filename> file, as the
+        <systemitem class="username">root</systemitem> user, copy the example
+        file to <filename>/etc/sddm.conf</filename>:
+      </para>
+
+<screen role="root"><userinput>cp -v sddm.example.conf /etc/sddm.conf</userinput></screen>
+
+      <para>
+        Normally, you want to edit this file. For example, if Xorg is installed
+        in /opt, use your preferred editor as the
+        <systemitem class="username">root</systemitem>
+        user to replace the <emphasis>XauthPath</emphasis> default path by
+        <emphasis>/usr/bin/xauth</emphasis>. Or, as the <systemitem
         class="username">root</systemitem> user, issue
       </para>
 
 <screen role="root"><userinput>sed -e '/ServerPath/ s|usr|opt/xorg|' \
-    -e '/XauthPath/  s|usr|opt/xorg|' \
     -i.orig /etc/sddm.conf</userinput></screen>
 
@@ -210,4 +238,31 @@
         This command will do the substitution and create a copy of the original
         file with name <filename>/etc/sddm.conf.orig</filename>.
+      </para>
+
+      <para>
+        From now on, we will describe how to modify configurations using sed,
+        but of course you may rather use your preferred editor as the
+        <systemitem class="username">root</systemitem>, instead. You generally
+        want the server option that comes in sddm.example.conf, for security
+        reasons.  Unless you want a remote machine to use the local X server,
+        in which case, as the <systemitem class="username">root</systemitem>
+        user, issue:
+      </para>
+
+<screen role="root"><userinput>sed -e 's/-nolisten tcp//'\
+    -i /etc/sddm.conf</userinput></screen>
+
+      <para>
+        Desktop (Notebook) users, normally wish the Num Lock key on (off).  For
+        that, as the <systemitem
+        class="username">root</systemitem> user, issue:
+      </para>
+
+<screen role="root"><userinput>sed -e 's/\"none\"/\"on\"/' \
+    -i /etc/sddm.conf</userinput></screen>
+
+      <para>
+        That was for Desktop users. For Notebook users,
+        replace \"on\" by \"off\", in the command above.
       </para>
 
@@ -378,4 +433,14 @@
       </para>
 
+      <note>
+        <para>
+          In the next couple of paragraphs, due to a problem with sddm-greeter,
+          we mention how to define the keyboard used there. Notice that this is
+          also the keyboard that will be used in the X session, unless there is
+          a configuration in the Desktop Environment or in the Window Manager
+          overriding it, afterwards.
+        </para>
+      </note>
+
       <para>
         Keyboard selection: the greeter shows a double question mark or the
@@ -391,6 +456,9 @@
 
       <para>
-        E.g. <command>echo 'setxkbmap "gb,br,us"' &gt;&gt;
-        /usr/share/sddm/scripts/Xsetup</command>
+        E.g. <command>echo 'setxkbmap "fr,gb,br,us"' &gt;&gt;
+        /usr/share/sddm/scripts/Xsetup</command>. You can be accurate defining
+        the keyboard(s), for example: <command>echo 'setxkbmap -model pc105
+        -layout br,us -variant abnt2,dvorak -keycodes evdev' &gt;&gt;
+        /usr/share/sddm/scripts/Xsetup</command>. See man setxkbmap.
       </para>
 
Index: x/installing/xinit.xml
===================================================================
--- x/installing/xinit.xml	(revision 1c2bec773011cbbd84bad8b02b760355ba52f32b)
+++ x/installing/xinit.xml	(revision eca7a588ace1ac770493bd6c224aa0300450ef34)
@@ -73,4 +73,11 @@
     <title>Installation of xinit</title>
 
+    <para>First, modify <command>startx</command>, hence the X session starts on
+    the first unused virtual terminal, which normally is vt7:</para>
+    <!--Apparently, this should not be done for systemd systems-->
+
+<screen><userinput>sed -e '/$serverargs $vtarg/ s/serverargs/: #&amp;/' \
+    -i startx.cpp</userinput></screen>
+
     <para>Install <application>xinit</application> by running the
     following commands:</para>
Index: xfce/core/xfce4-session.xml
===================================================================
--- xfce/core/xfce4-session.xml	(revision 1c2bec773011cbbd84bad8b02b760355ba52f32b)
+++ xfce/core/xfce4-session.xml	(revision eca7a588ace1ac770493bd6c224aa0300450ef34)
@@ -87,6 +87,6 @@
     <bridgehead renderas="sect4">Recommended</bridgehead>
     <para role="recommended">
-      <xref linkend="desktop-file-utils"/> 
-      <xref linkend="shared-mime-info"/>, and
+      <xref linkend="desktop-file-utils"/>,
+      <xref linkend="shared-mime-info"/> and
       <xref linkend="polkit-gnome"/>
     </para>
@@ -150,13 +150,13 @@
       <xref linkend="openssh"/>
     </para>
-
+<!--
     <para>
       To launch <application>Xfce4</application> use the command
       <command>startxfce4</command>. If you have <xref linkend="consolekit"/>
-      installed, use <command>startxfce4 --with-ck-launch</command>.
+      installed, use <command>startxfce4 -\-with-ck-launch</command>.
       <application>ConsoleKit</application> is required to perform any
       task that requires administrative access, including shut down
       and reboot.
-    </para>
+    </para>-->
 
     <para>
@@ -174,4 +174,54 @@
 <screen role="root"><userinput>update-desktop-database &amp;&amp;
 update-mime-database</userinput></screen>
+  </sect2>
+
+  <sect2 role="starting">
+    <title>Starting Xfce4</title>
+
+    <para>
+      You can start <application>Xfce4</application> from runlevel 3, using
+      <xref linkend="xinit"/>, or from runlevel 5, using a Display Manager,
+      such as <xref linkend="sddm"/>.
+    </para>
+
+    <para>
+      To start <application>Xfce4</application> using <xref linkend="xinit"/>,
+      run the following commands:
+    </para>
+
+<screen><userinput>cat &gt; ~/.xinitrc &lt;&lt; "EOF"
+<literal>ck-launch-session dbus-launch --exit-with-session startxfce4</literal>
+EOF
+
+startx</userinput></screen>
+
+    <para>
+      The X session starts on the first unused virtual terminal, normally vt7.
+      You can switch to a vtn (n=1, 2, ...) simultaneously pressing the keys
+      Ctrl-Alt-Fn. To switch back to the X session, normally started at vt7,
+      use Ctrl-Alt-F7. If started from vt1 (the usual case), you will see many
+      messages there, including X starting messages, applications automatically
+      started with the session, and eventually, some warning and error
+      messages. You may prefer to redirect those messages to a log file, which
+      not only will keep vt1 uncluttered, but also can be used for debug
+      purposes. This can be done starting X with:
+    </para>
+
+    <screen><userinput>startx &amp;&gt; ~/.x-session-errors</userinput></screen>
+
+    <para>
+      You may wish to drop consolekit and/or dbus-launch, e.g., just using
+      startlxde in .~/.xinitrc, but some functionalities such as mount/umount
+      file systems from a file manager will not be possible, or the reboot
+      option will be absent or not functioning, between other problems.
+    </para>
+
+    <para>
+      Because X is (normally) on vt7, when you shutdown the vt is switched back
+      to that one where the command starting it was executed. In this case, if
+      you wish to see the shutdown messages, simultaneously press keys Alt-F7,
+      because normally those messages appear on the vt where X was running.
+    </para>
+
   </sect2>
 
