guix-commits
[Top][All Lists]
Advanced

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

02/03: services: slim: Preserve the order of session types.


From: Ludovic Courtès
Subject: 02/03: services: slim: Preserve the order of session types.
Date: Thu, 26 Feb 2015 21:25:24 +0000

civodul pushed a commit to branch master
in repository guix.

commit a21b23d34a68fda0a57b5be67f61cffae8db59cd
Author: Ludovic Courtès <address@hidden>
Date:   Thu Feb 26 22:17:21 2015 +0100

    services: slim: Preserve the order of session types.
    
    That makes WindowMaker the default session, by default.
    
    * gnu/services/xorg.scm (xsessions-directory)[builder]: Prepend a number
      in the file name to preserve the order of SESSIONS.
      (slim-service): Augment docstring.
    * doc/guix.texi (X Window): Adjust accordingly.
---
 doc/guix.texi         |    3 ++-
 gnu/services/xorg.scm |   33 ++++++++++++++++++++++-----------
 2 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 81b9353..bd8091a 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -4634,7 +4634,8 @@ theme to use.  In that case, @var{theme-name} specifies 
the name of the
 theme.
 
 Last, @var{session} is a list of @code{<session-type>} objects denoting the
-available session types that can be chosen from the log-in screen.
+available session types that can be chosen from the log-in screen.  The first
+one is chosen by default.
 @end deffn
 
 @defvr {Scheme Variable} %default-sessions
diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm
index 7cb9012..f990d1a 100644
--- a/gnu/services/xorg.scm
+++ b/gnu/services/xorg.scm
@@ -207,23 +207,33 @@ which should be passed to this script as the first 
argument.  If not, the
   (list %windowmaker-session-type %ratpoison-session-type))
 
 (define (xsessions-directory sessions)
-  "Return a directory containing SESSIONS, a list of <session-type> objects."
+  "Return a directory containing SESSIONS, a list of <session-type> objects.
+The alphabetical order of the files in that directory match the order of the
+elements in SESSIONS."
   (define builder
     #~(begin
+        (use-modules (srfi srfi-1)
+                     (ice-9 format))
+
         (mkdir #$output)
         (chdir #$output)
-        (for-each (lambda (name executable)
-                    (let ((file (string-append (string-downcase name)
-                                               ".desktop")))
-                      (call-with-output-file file
-                        (lambda (port)
-                          (format port "[Desktop Entry]
+        (fold (lambda (name executable number)
+                ;; Create file names such that the order of the items in
+                ;; SESSION is respected.  SLiM gets them in lexicographic
+                ;; order and uses the first one as the default session.
+                (let ((file (format #f "~2,'0d-~a.desktop"
+                                    number (string-downcase name))))
+                  (call-with-output-file file
+                    (lambda (port)
+                      (format port "[Desktop Entry]
 Name=~a
 Exec=~a
 Type=Application~%"
-                                  name executable)))))
-                  '#$(map session-type-name sessions)
-                  (list #$@(map session-type-executable sessions)))))
+                              name executable)))
+                  (+ 1 number)))
+              1
+              '#$(map session-type-name sessions)
+              (list #$@(map session-type-executable sessions)))))
 
   (gexp->derivation "xsessions-dir" builder))
 
@@ -260,7 +270,8 @@ theme to use.  In that case, @var{theme-name} specifies the 
name of the
 theme.
 
 Last, @var{session} is a list of @code{<session-type>} objects denoting the
-available session types that can be chosen from the log-in screen."
+available session types that can be chosen from the log-in screen.  The first
+one is chosen by default."
 
   (define (slim.cfg)
     (mlet %store-monad ((startx  (or startx (xorg-start-command)))



reply via email to

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