summary refs log tree commit diff
path: root/gnu/services/xorg.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-12-13 16:17:23 +0100
committerLudovic Courtès <ludo@gnu.org>2014-12-13 16:22:34 +0100
commitb2bd7c253a9798630e983ac801e28aeb6b01cb1f (patch)
treef10973e8be0efec40a13c4df332c1fd507bab0d5 /gnu/services/xorg.scm
parenta8a086e3928371863b23451f52210d74f4c78ab8 (diff)
downloadguix-b2bd7c253a9798630e983ac801e28aeb6b01cb1f.tar.gz
services: xorg: Run the window manager from a login shell.
This is a followup to 1d18d87, which fixes <http://bugs.gnu.org/19119>.

* gnu/services/xorg.scm (xinitrc)[builder]: Add 'exec-from-login-shell'
  procedure.  Use it instead of 'execl' when launching XSESSION, WMAKER,
  or RATPOISON.
Diffstat (limited to 'gnu/services/xorg.scm')
-rw-r--r--gnu/services/xorg.scm29
1 files changed, 16 insertions, 13 deletions
diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm
index c813f0fb1e..fbf96c799b 100644
--- a/gnu/services/xorg.scm
+++ b/gnu/services/xorg.scm
@@ -143,28 +143,31 @@ EndSection
     #~(begin
         (use-modules (ice-9 match))
 
+        (define (exec-from-login-shell command . args)
+          ;; Run COMMAND from a login shell so that it gets to see the same
+          ;; environment variables that one gets when logging in on a tty, for
+          ;; instance.
+          (let* ((pw    (getpw (getuid)))
+                 (shell (passwd:shell pw))
+                 (st    (stat command #f)))
+            (when (and st (not (zero? (logand (stat:mode st) #o100))))
+              ;; The '--login' option is supported at least by Bash and zsh.
+              (execl shell shell "--login" "-c"
+                     (string-join (cons command args))))))
+
+        ;; First, try to run ~/.xsession.
         (let* ((home     (getenv "HOME"))
-               (profile  (string-append home "/.guix-profile/bin"))
-               (PATH     (or (getenv "PATH") ""))
                (xsession (string-append home "/.xsession")))
-          ;; Make sure the user's profile is visible.
-          (setenv "PATH"
-                  (string-append profile
-                                 (if (string-null? PATH) "" ":")
-                                 PATH))
-
-          ;; First, try to run ~/.xsession.
-          (false-if-exception (execl xsession xsession)))
+          (exec-from-login-shell xsession))
 
         ;; Then try a pre-configured session type.
         (let ((ratpoison (string-append #$ratpoison "/bin/ratpoison"))
               (wmaker    (string-append #$windowmaker "/bin/wmaker")))
           (match (command-line)
             ((_ "ratpoison")
-             (execl ratpoison ratpoison))
+             (exec-from-login-shell ratpoison))
             (_
-             ;; 'wmaker' does execvp(argv[0]), so we really can't mess up.
-             (execl wmaker wmaker))))))
+             (exec-from-login-shell wmaker))))))
 
   (gexp->script "xinitrc" builder))