guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

10/10: services: xorg: Remove WindowMaker as a default fallback.


From: Ludovic Courtès
Subject: 10/10: services: xorg: Remove WindowMaker as a default fallback.
Date: Tue, 28 Nov 2017 05:25:49 -0500 (EST)

civodul pushed a commit to branch master
in repository guix.

commit 65c0f43649b455db94f1e8b0a244a889cb961b25
Author: Ludovic Courtès <address@hidden>
Date:   Sat Nov 25 23:19:31 2017 +0100

    services: xorg: Remove WindowMaker as a default fallback.
    
    * gnu/services/xorg.scm (xinitrc)[builder](system-profile)
    (user-profile): New variables.
    (xsession-command, find-session): New procedures.
    When FALLBACK-SESSION is #f, find a valid session at run time.
    * doc/guix.texi (X Window): Adjust accordingly, and insist that one
    or more window managers must be installed.
---
 doc/guix.texi         | 24 ++++++++++++++++---
 gnu/services/xorg.scm | 65 ++++++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 77 insertions(+), 12 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index c3b97ce..05042cb 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -10996,10 +10996,17 @@ Package object of the Open vSwitch.
 
 @cindex X11
 @cindex X Window System
address@hidden login manager
 Support for the X Window graphical display system---specifically
 Xorg---is provided by the @code{(gnu services xorg)} module.  Note that
 there is no @code{xorg-service} procedure.  Instead, the X server is
-started by the @dfn{login manager}, currently SLiM.
+started by the @dfn{login manager}, by default SLiM.
+
address@hidden window manager
+To use X11, you must install at least one @dfn{window manager}---for
+example the @code{windowmaker} or @code{openbox} packages---preferably
+by adding it to the @code{packages} field of your operating system
+definition (@pxref{operating-system Reference, system-wide packages}).
 
 @defvr {Scheme Variable} slim-service-type
 This is the type for the SLiM graphical login manager for X11.
@@ -11036,8 +11043,19 @@ When @code{auto-login?} is true, SLiM logs in directly 
as
 @itemx @code{theme-name} (default: @code{%default-slim-theme-name})
 The graphical theme to use and its name.
 
address@hidden @code{auto-login-session} (default: @code{windowmaker})
-The default session to use when none is specified.
address@hidden @code{auto-login-session} (default: @code{#f})
+If true, this must be the name of the executable to start as the default
+session---e.g., @code{(file-append windowmaker "/bin/windowmaker")}.
+
+If false, a session described by one of the available @file{.desktop}
+files in @code{/run/current-system/profile} and @code{~/.guix-profile}
+will be used.
+
address@hidden Note
+You must install at least one window manager in the system profile or in
+your user profile.  Failing to do that, if @code{auto-login-session} is
+false, you will be unable to log in.
address@hidden quotation
 
 @item @code{startx} (default: @code{(xorg-start-command)})
 The command used to start the X11 graphical server.
diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm
index c1955e0..0da3397 100644
--- a/gnu/services/xorg.scm
+++ b/gnu/services/xorg.scm
@@ -309,10 +309,15 @@ used in place of @code{startx}."
                   fallback-session)
   "Return a system-wide xinitrc script that starts the specified X session,
 which should be passed to this script as the first argument.  If not, the
address@hidden will be used."
address@hidden will be used or, if @var{fallback-session} is false, a
+desktop session from the system or user profile will be used."
   (define builder
     #~(begin
-        (use-modules (ice-9 match))
+        (use-modules (ice-9 match)
+                     (ice-9 regex)
+                     (ice-9 ftw)
+                     (srfi srfi-1)
+                     (srfi srfi-26))
 
         (define (close-all-fdes)
           ;; Close all the open file descriptors except 0 to 2.
@@ -336,16 +341,59 @@ which should be passed to this script as the first 
argument.  If not, the
             (execl shell shell "--login" "-c"
                    (string-join (cons command args)))))
 
+        (define system-profile
+          "/run/current-system/profile")
+
+        (define user-profile
+          (and=> (getpw (getuid))
+                 (lambda (pw)
+                   (string-append (passwd:dir pw) "/.guix-profile"))))
+
+        (define (xsession-command desktop-file)
+          ;; Read from DESKTOP-FILE its X session command and return it as a
+          ;; list.
+          (define exec-regexp
+            (make-regexp "^[[:blank:]]*Exec=(.*)$"))
+
+          (call-with-input-file desktop-file
+            (lambda (port)
+              (let loop ()
+                (match (read-line port)
+                  ((? eof-object?) #f)
+                  ((= (cut regexp-exec exec-regexp <>) result)
+                   (if result
+                       (string-tokenize (match:substring result 1))
+                       (loop))))))))
+
+        (define (find-session profile)
+          ;; Return an X session command from PROFILE or #f if none was found.
+          (let ((directory (string-append profile "/share/xsessions")))
+            (match (scandir directory
+                            (cut string-suffix? ".desktop" <>))
+              ((or () #f)
+               #f)
+              ((sessions ...)
+               (any xsession-command
+                    (map (cut string-append directory "/" <>)
+                         sessions))))))
+
         (let* ((home          (getenv "HOME"))
                (xsession-file (string-append home "/.xsession"))
                (session       (match (command-line)
-                                ((_)       (list #$fallback-session))
-                                ((_ x ..1) x))))
+                                ((_)
+                                 #$(if fallback-session
+                                       #~(list #$fallback-session)
+                                       #f))
+                                ((_ x ..1)
+                                 x))))
           (if (file-exists? xsession-file)
               ;; Run ~/.xsession when it exists.
               (apply exec-from-login-shell xsession-file session)
-              ;; Otherwise, start the specified session.
-              (apply exec-from-login-shell session)))))
+              ;; Otherwise, start the specified session or a fallback.
+              (apply exec-from-login-shell
+                     (or session
+                         (find-session user-profile)
+                         (find-session system-profile)))))))
 
   (program-file "xinitrc" builder))
 
@@ -383,7 +431,7 @@ which should be passed to this script as the first 
argument.  If not, the
   (shepherd slim-configuration-shepherd
             (default shepherd))
   (auto-login-session slim-configuration-auto-login-session
-                      (default (file-append windowmaker "/bin/wmaker")))
+                      (default #f))
   (startx slim-configuration-startx
           (default (xorg-start-command))))
 
@@ -469,8 +517,7 @@ reboot_cmd " shepherd "/sbin/reboot\n"
                        (theme %default-slim-theme)
                        (theme-name %default-slim-theme-name)
                        (xauth xauth) (shepherd shepherd)
-                       (auto-login-session (file-append windowmaker
-                                                        "/bin/wmaker"))
+                       (auto-login-session #f)
                        (startx (xorg-start-command)))
   "Return a service that spawns the SLiM graphical login manager, which in
 turn starts the X display server with @var{startx}, a command as returned by



reply via email to

[Prev in Thread] Current Thread [Next in Thread]