* [PATCH] services: xorg: Make SLiM sessions configurable.
@ 2014-12-15 16:30 宋文武
2014-12-16 23:03 ` Ludovic Courtès
0 siblings, 1 reply; 6+ messages in thread
From: 宋文武 @ 2014-12-15 16:30 UTC (permalink / raw)
To: guix-devel
* gnu/services/xorg.scm (%default-xsessions): New variable.
(xsessions-directory): New procedure.
(slim-service): Add #:sessions parameter.
[slim.cfg]: Honor #:sessions.
(xinitrc): Adjust accordingly.
---
gnu/services/xorg.scm | 50 +++++++++++++++++++++++++++++++++++---------------
1 file changed, 35 insertions(+), 15 deletions(-)
diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm
index fbf96c7..73f669d 100644
--- a/gnu/services/xorg.scm
+++ b/gnu/services/xorg.scm
@@ -36,7 +36,7 @@
#:use-module (srfi srfi-26)
#:use-module (ice-9 match)
#:export (xorg-start-command
-
+ %default-xsessions
%default-slim-theme
%default-slim-theme-name
slim-service))
@@ -135,9 +135,7 @@ EndSection
(gexp->script "start-xorg" script)))
(define* (xinitrc #:key
- (guile (canonical-package guile-2.0))
- (ratpoison ratpoison)
- (windowmaker windowmaker))
+ (guile (canonical-package guile-2.0)))
"Return a system-wide xinitrc script that starts the specified X session."
(define builder
#~(begin
@@ -160,15 +158,8 @@ EndSection
(xsession (string-append home "/.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")
- (exec-from-login-shell ratpoison))
- (_
- (exec-from-login-shell wmaker))))))
-
+ ;; Then run the selected session.
+ (exec-from-login-shell (cadr command-line))))
(gexp->script "xinitrc" builder))
\f
@@ -176,6 +167,33 @@ EndSection
;;; SLiM log-in manager.
;;;
+(define %default-xsessions
+ (list (text-file* "wmaker.desktop" "
+[Desktop Entry]
+Name=Window Maker
+Exec=" windowmaker "/bin/wmaker
+Type=Application
+")
+ (text-file* "ratpoison.desktop" "
+[Desktop Entry]
+Name=Ratpoison
+Exec=" ratpoison "/bin/ratpoison
+Type=Application
+")))
+
+(define (xsessions-directory sessions)
+ "Return a directory contains SESSIONS, which should be a list of monadic
+desktop entries."
+ (mlet %store-monad ((sessions (sequence %store-monad sessions)))
+ (define builder
+ #~(begin
+ (mkdir #$output)
+ (for-each (lambda (session)
+ (symlink session (string-append #$output "/"
+ (basename session))))
+ '#$sessions)))
+ (gexp->derivation "xsessions-dir" builder)))
+
(define %default-slim-theme
;; Theme based on work by Felipe López.
#~(string-append #$%artwork-repository "/slim"))
@@ -191,6 +209,7 @@ EndSection
(theme %default-slim-theme)
(theme-name %default-slim-theme-name)
(xauth xauth) (dmd dmd) (bash bash)
+ (sessions %default-xsessions)
startx)
"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
@@ -207,7 +226,8 @@ theme."
(define (slim.cfg)
(mlet %store-monad ((startx (or startx (xorg-start-command)))
- (xinitrc (xinitrc)))
+ (xinitrc (xinitrc))
+ (sessiondir (xsessions-directory sessions)))
(text-file* "slim.cfg" "
default_path /run/current-system/profile/bin
default_xserver " startx "
@@ -218,7 +238,7 @@ authfile /var/run/slim.auth
# The login command. '%session' is replaced by the chosen session name, one
# of the names specified in the 'sessions' setting: 'wmaker', 'xfce', etc.
login_cmd exec " xinitrc " %session
-sessions wmaker,ratpoison
+sessiondir " sessiondir "
halt_cmd " dmd "/sbin/halt
reboot_cmd " dmd "/sbin/reboot
--
2.1.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] services: xorg: Make SLiM sessions configurable.
2014-12-15 16:30 [PATCH] services: xorg: Make SLiM sessions configurable 宋文武
@ 2014-12-16 23:03 ` Ludovic Courtès
2014-12-19 16:08 ` 宋文武
0 siblings, 1 reply; 6+ messages in thread
From: Ludovic Courtès @ 2014-12-16 23:03 UTC (permalink / raw)
To: 宋文武; +Cc: guix-devel
宋文武 <iyzsong@gmail.com> skribis:
> * gnu/services/xorg.scm (%default-xsessions): New variable.
> (xsessions-directory): New procedure.
> (slim-service): Add #:sessions parameter.
> [slim.cfg]: Honor #:sessions.
> (xinitrc): Adjust accordingly.
Nice!
> - ;; Then try a pre-configured session type.
> - (let ((ratpoison (string-append #$ratpoison "/bin/ratpoison"))
> - (wmaker (string-append #$windowmaker "/bin/wmaker")))
> - (match (command-line)
> - ((_ "ratpoison")
> - (exec-from-login-shell ratpoison))
> - (_
> - (exec-from-login-shell wmaker))))))
> -
> + ;; Then run the selected session.
> + (exec-from-login-shell (cadr command-line))))
Please keep ‘match’ instead of ‘cadr’.
Also, the line above should be (cadr (command-line)) instead of (cadr
command-line).
Lastly, there’s a problem when #:auto-login? is #t because
(command-line) returns a 1-element list. This will be naturally fixed
when the ‘match’ form above is reinstated.
> +(define %default-xsessions
> + (list (text-file* "wmaker.desktop" "
Add a comment below ‘%default-xsessions’, like
;; List of monadic values denoting for .desktop files blah blah
> +(define (xsessions-directory sessions)
> + "Return a directory contains SESSIONS, which should be a list of monadic
s/contains/containing/
Other than that, it looks fine to me. Could you send an updated
version?
Thanks!
Ludo’.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] services: xorg: Make SLiM sessions configurable.
2014-12-16 23:03 ` Ludovic Courtès
@ 2014-12-19 16:08 ` 宋文武
2014-12-19 21:24 ` Ludovic Courtès
0 siblings, 1 reply; 6+ messages in thread
From: 宋文武 @ 2014-12-19 16:08 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel
[-- Attachment #1: Type: text/plain, Size: 1782 bytes --]
Ludovic Courtès <ludo@gnu.org> writes:
> 宋文武 <iyzsong@gmail.com> skribis:
>
>> * gnu/services/xorg.scm (%default-xsessions): New variable.
>> (xsessions-directory): New procedure.
>> (slim-service): Add #:sessions parameter.
>> [slim.cfg]: Honor #:sessions.
>> (xinitrc): Adjust accordingly.
>
> Nice!
>
>> - ;; Then try a pre-configured session type.
>> - (let ((ratpoison (string-append #$ratpoison "/bin/ratpoison"))
>> - (wmaker (string-append #$windowmaker "/bin/wmaker")))
>> - (match (command-line)
>> - ((_ "ratpoison")
>> - (exec-from-login-shell ratpoison))
>> - (_
>> - (exec-from-login-shell wmaker))))))
>> -
>> + ;; Then run the selected session.
>> + (exec-from-login-shell (cadr command-line))))
>
> Please keep ‘match’ instead of ‘cadr’.
OK.
>
> Also, the line above should be (cadr (command-line)) instead of (cadr
> command-line).
>
> Lastly, there’s a problem when #:auto-login? is #t because
> (command-line) returns a 1-element list. This will be naturally fixed
> when the ‘match’ form above is reinstated.
Thanks for pointing out.
I want to make this auto-login-session configurable too, so I endup
with add it as a parameter to slim-service.
>
>> +(define %default-xsessions
>> + (list (text-file* "wmaker.desktop" "
>
> Add a comment below ‘%default-xsessions’, like
>
> ;; List of monadic values denoting for .desktop files blah blah
>
>> +(define (xsessions-directory sessions)
>> + "Return a directory contains SESSIONS, which should be a list of monadic
>
> s/contains/containing/
>
> Other than that, it looks fine to me. Could you send an updated
> version?
[-- Attachment #2: 0001-services-xorg-Make-SLiM-sessions-configurable.patch --]
[-- Type: text/x-patch, Size: 5942 bytes --]
From 144bf00b86f6884615d986598ccc62a3c4747eef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@gmail.com>
Date: Tue, 16 Dec 2014 00:21:46 +0800
Subject: [PATCH] services: xorg: Make SLiM sessions configurable.
* gnu/services/xorg.scm (%default-xsessions): New variable.
(xsessions-directory): New procedure.
(slim-service): Add #:sessions and #:auto-login-session parameters.
[slim.cfg]: Honor #:sessions.
(xinitrc): Adjust accordingly.
---
gnu/services/xorg.scm | 71 ++++++++++++++++++++++++++++++++++++---------------
1 file changed, 50 insertions(+), 21 deletions(-)
diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm
index fbf96c7..37f3753 100644
--- a/gnu/services/xorg.scm
+++ b/gnu/services/xorg.scm
@@ -36,7 +36,7 @@
#:use-module (srfi srfi-26)
#:use-module (ice-9 match)
#:export (xorg-start-command
-
+ %default-xsessions
%default-slim-theme
%default-slim-theme-name
slim-service))
@@ -136,9 +136,10 @@ EndSection
(define* (xinitrc #:key
(guile (canonical-package guile-2.0))
- (ratpoison ratpoison)
- (windowmaker windowmaker))
- "Return a system-wide xinitrc script that starts the specified X session."
+ 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
+FALLBACK-SESSION will be used."
(define builder
#~(begin
(use-modules (ice-9 match))
@@ -155,20 +156,14 @@ EndSection
(execl shell shell "--login" "-c"
(string-join (cons command args))))))
- ;; First, try to run ~/.xsession.
- (let* ((home (getenv "HOME"))
- (xsession (string-append home "/.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")
- (exec-from-login-shell ratpoison))
- (_
- (exec-from-login-shell wmaker))))))
-
+ (let ((home (getenv "HOME"))
+ (session (match (command-line)
+ ((_ x) x)
+ (_ #$fallback-session))))
+ ;; First, try to run ~/.xinitrc with the specified session.
+ (exec-from-login-shell (string-append home "/.xinitrc") session)
+ ;; Then starts the specified session directly.
+ (exec-from-login-shell session))))
(gexp->script "xinitrc" builder))
\f
@@ -176,6 +171,35 @@ EndSection
;;; SLiM log-in manager.
;;;
+(define %default-xsessions
+ ;; Default xsessions available for log-in manager, representing as a list of
+ ;; monadic desktop entries.
+ (list (text-file* "wmaker.desktop" "
+[Desktop Entry]
+Name=Window Maker
+Exec=" windowmaker "/bin/wmaker
+Type=Application
+")
+ (text-file* "ratpoison.desktop" "
+[Desktop Entry]
+Name=Ratpoison
+Exec=" ratpoison "/bin/ratpoison
+Type=Application
+")))
+
+(define (xsessions-directory sessions)
+ "Return a directory containing SESSIONS, which should be a list of monadic
+desktop entries."
+ (mlet %store-monad ((sessions (sequence %store-monad sessions)))
+ (define builder
+ #~(begin
+ (mkdir #$output)
+ (for-each (lambda (session)
+ (symlink session (string-append #$output "/"
+ (basename session))))
+ '#$sessions)))
+ (gexp->derivation "xsessions-dir" builder)))
+
(define %default-slim-theme
;; Theme based on work by Felipe López.
#~(string-append #$%artwork-repository "/slim"))
@@ -191,6 +215,9 @@ EndSection
(theme %default-slim-theme)
(theme-name %default-slim-theme-name)
(xauth xauth) (dmd dmd) (bash bash)
+ (sessions %default-xsessions)
+ (auto-login-session #~(string-append #$windowmaker
+ "/bin/wmaker"))
startx)
"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
@@ -198,7 +225,7 @@ turn starts the X display server with @var{startx}, a command as returned by
When @var{allow-empty-passwords?} is true, allow logins with an empty
password. When @var{auto-login?} is true, log in automatically as
-@var{default-user}.
+@var{default-user} with @var{auto-login-session}.
If @var{theme} is @code{#f}, the use the default log-in theme; otherwise
@var{theme} must be a gexp denoting the name of a directory containing the
@@ -207,7 +234,9 @@ theme."
(define (slim.cfg)
(mlet %store-monad ((startx (or startx (xorg-start-command)))
- (xinitrc (xinitrc)))
+ (xinitrc (xinitrc #:fallback-session
+ auto-login-session))
+ (sessiondir (xsessions-directory sessions)))
(text-file* "slim.cfg" "
default_path /run/current-system/profile/bin
default_xserver " startx "
@@ -218,7 +247,7 @@ authfile /var/run/slim.auth
# The login command. '%session' is replaced by the chosen session name, one
# of the names specified in the 'sessions' setting: 'wmaker', 'xfce', etc.
login_cmd exec " xinitrc " %session
-sessions wmaker,ratpoison
+sessiondir " sessiondir "
halt_cmd " dmd "/sbin/halt
reboot_cmd " dmd "/sbin/reboot
--
2.1.2
[-- Attachment #3: Type: text/plain, Size: 433 bytes --]
In additation, I pass session to ~/.xinitrc (replace ~/.xsession, since
it's what to expect from slim according to [1][2]).
So user can use ~/.xinitrc to custom the selected session:
#!/bin/sh
export LANG=zh_CN.UTF-8
setxkbmap dvorak
exec $1
[1] https://wiki.archlinux.org/index.php/Slim#Environments
[2] https://lists.gnu.org/archive/html/guix-devel/2014-12/msg00282.html
>
> Thanks!
>
> Ludo’.
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] services: xorg: Make SLiM sessions configurable.
2014-12-19 16:08 ` 宋文武
@ 2014-12-19 21:24 ` Ludovic Courtès
2014-12-20 3:12 ` 宋文武
0 siblings, 1 reply; 6+ messages in thread
From: Ludovic Courtès @ 2014-12-19 21:24 UTC (permalink / raw)
To: 宋文武; +Cc: guix-devel
宋文武 <iyzsong@gmail.com> skribis:
> From 144bf00b86f6884615d986598ccc62a3c4747eef Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@gmail.com>
> Date: Tue, 16 Dec 2014 00:21:46 +0800
> Subject: [PATCH] services: xorg: Make SLiM sessions configurable.
>
> * gnu/services/xorg.scm (%default-xsessions): New variable.
> (xsessions-directory): New procedure.
> (slim-service): Add #:sessions and #:auto-login-session parameters.
> [slim.cfg]: Honor #:sessions.
> (xinitrc): Adjust accordingly.
LGTM. However, please leave .xsession (instead of .xinitrc) in this
patch. The change to .xinitrd should be done separately.
> + ;; First, try to run ~/.xinitrc with the specified session.
> + (exec-from-login-shell (string-append home "/.xinitrc") session)
> + ;; Then starts the specified session directly.
> + (exec-from-login-shell session))))
s/Then starts/Then try to start/
OK to push with these two changes.
> In additation, I pass session to ~/.xinitrc (replace ~/.xsession, since
> it's what to expect from slim according to [1][2]).
[...]
> [1] https://wiki.archlinux.org/index.php/Slim#Environments
> [2] https://lists.gnu.org/archive/html/guix-devel/2014-12/msg00282.html
I wasn’t sure about .xsession vs .xinitrc, so I did some research.
<https://wiki.ubuntu.com/CustomXSession> reads:
Your login script, .xinitrc, works with startx, but graphical login
managers like GDM do not look for .xinitrc. Instead, they look for a
file named .xsession in your home directory.
Likewise, <https://wiki.debian.org/Xinitrc> reads:
Note that ~/.xinitrc is only for configuring the initialization of
xinit. If you want the script to be called when ever an X Session is
started, then you should instead use ~/.xsession.
Someone at
<http://unix.stackexchange.com/questions/47359/what-is-xsession-for>
writes:
If you log in in graphical mode on an X display manager (xdm, gdm,
kdm, wdm, lightdm, …), traditionally, what is executed after you log
in is some scripts in /etc/X11 then ~/.xsession.
Citing the ‘startx’ man page on Debian at
<http://marc.info/?l=debian-user&m=108078928208265>:
Keep in mind that .xinitrc is used only by xinit(1) and completely
ignored by xdm(1).
So it seems that the Right Thing is to use ~/.xsession in our case.
WDYT?
(I think we should provide a ‘startx’ command as well eventually, and it
will have to read .xinitrc.)
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] services: xorg: Make SLiM sessions configurable.
2014-12-19 21:24 ` Ludovic Courtès
@ 2014-12-20 3:12 ` 宋文武
2014-12-21 11:09 ` Ludovic Courtès
0 siblings, 1 reply; 6+ messages in thread
From: 宋文武 @ 2014-12-20 3:12 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel
Ludovic Courtès <ludo@gnu.org> writes:
> 宋文武 <iyzsong@gmail.com> skribis:
>
>> From 144bf00b86f6884615d986598ccc62a3c4747eef Mon Sep 17 00:00:00 2001
>> From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@gmail.com>
>> Date: Tue, 16 Dec 2014 00:21:46 +0800
>> Subject: [PATCH] services: xorg: Make SLiM sessions configurable.
>>
>> * gnu/services/xorg.scm (%default-xsessions): New variable.
>> (xsessions-directory): New procedure.
>> (slim-service): Add #:sessions and #:auto-login-session parameters.
>> [slim.cfg]: Honor #:sessions.
>> (xinitrc): Adjust accordingly.
>
> LGTM. However, please leave .xsession (instead of .xinitrc) in this
> patch. The change to .xinitrd should be done separately.
>
>> + ;; First, try to run ~/.xinitrc with the specified session.
>> + (exec-from-login-shell (string-append home "/.xinitrc") session)
>> + ;; Then starts the specified session directly.
>> + (exec-from-login-shell session))))
>
> s/Then starts/Then try to start/
>
> OK to push with these two changes.
Done, thanks for review!
>
>> In additation, I pass session to ~/.xinitrc (replace ~/.xsession, since
>> it's what to expect from slim according to [1][2]).
>
> [...]
>
>> [1] https://wiki.archlinux.org/index.php/Slim#Environments
>> [2] https://lists.gnu.org/archive/html/guix-devel/2014-12/msg00282.html
>
> I wasn’t sure about .xsession vs .xinitrc, so I did some research.
>
> <https://wiki.ubuntu.com/CustomXSession> reads:
>
> Your login script, .xinitrc, works with startx, but graphical login
> managers like GDM do not look for .xinitrc. Instead, they look for a
> file named .xsession in your home directory.
>
> Likewise, <https://wiki.debian.org/Xinitrc> reads:
>
> Note that ~/.xinitrc is only for configuring the initialization of
> xinit. If you want the script to be called when ever an X Session is
> started, then you should instead use ~/.xsession.
>
> Someone at
> <http://unix.stackexchange.com/questions/47359/what-is-xsession-for>
> writes:
>
> If you log in in graphical mode on an X display manager (xdm, gdm,
> kdm, wdm, lightdm, …), traditionally, what is executed after you log
> in is some scripts in /etc/X11 then ~/.xsession.
>
> Citing the ‘startx’ man page on Debian at
> <http://marc.info/?l=debian-user&m=108078928208265>:
>
> Keep in mind that .xinitrc is used only by xinit(1) and completely
> ignored by xdm(1).
>
> So it seems that the Right Thing is to use ~/.xsession in our case.
> WDYT?
OK, it seem that only SLiM use ~/.xinitrc instead of ~/.xsession.
IMO, It's fine to stick with ~/.xsession if we add other login
managers later.
>
> (I think we should provide a ‘startx’ command as well eventually, and it
> will have to read .xinitrc.)
>
> Thanks,
> Ludo’.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] services: xorg: Make SLiM sessions configurable.
2014-12-20 3:12 ` 宋文武
@ 2014-12-21 11:09 ` Ludovic Courtès
0 siblings, 0 replies; 6+ messages in thread
From: Ludovic Courtès @ 2014-12-21 11:09 UTC (permalink / raw)
To: 宋文武; +Cc: guix-devel
宋文武 <iyzsong@gmail.com> skribis:
> Ludovic Courtès <ludo@gnu.org> writes:
>
>> 宋文武 <iyzsong@gmail.com> skribis:
>>
>>> From 144bf00b86f6884615d986598ccc62a3c4747eef Mon Sep 17 00:00:00 2001
>>> From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@gmail.com>
>>> Date: Tue, 16 Dec 2014 00:21:46 +0800
>>> Subject: [PATCH] services: xorg: Make SLiM sessions configurable.
>>>
>>> * gnu/services/xorg.scm (%default-xsessions): New variable.
>>> (xsessions-directory): New procedure.
>>> (slim-service): Add #:sessions and #:auto-login-session parameters.
>>> [slim.cfg]: Honor #:sessions.
>>> (xinitrc): Adjust accordingly.
>>
>> LGTM. However, please leave .xsession (instead of .xinitrc) in this
>> patch. The change to .xinitrd should be done separately.
>>
>>> + ;; First, try to run ~/.xinitrc with the specified session.
>>> + (exec-from-login-shell (string-append home "/.xinitrc") session)
>>> + ;; Then starts the specified session directly.
>>> + (exec-from-login-shell session))))
>>
>> s/Then starts/Then try to start/
>>
>> OK to push with these two changes.
> Done, thanks for review!
Great.
> OK, it seem that only SLiM use ~/.xinitrc instead of ~/.xsession.
> IMO, It's fine to stick with ~/.xsession if we add other login
> managers later.
Sounds good to me.
Thank you!
Ludo’.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-12-21 11:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-15 16:30 [PATCH] services: xorg: Make SLiM sessions configurable 宋文武
2014-12-16 23:03 ` Ludovic Courtès
2014-12-19 16:08 ` 宋文武
2014-12-19 21:24 ` Ludovic Courtès
2014-12-20 3:12 ` 宋文武
2014-12-21 11:09 ` Ludovic Courtès
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).