[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03/05: installer: Infer likely entries for user accounts from the gecos
From: |
John Darrington |
Subject: |
03/05: installer: Infer likely entries for user accounts from the gecos field. |
Date: |
Mon, 13 Feb 2017 16:00:56 -0500 (EST) |
jmd pushed a commit to branch wip-installer
in repository guix.
commit 82f77e46d0d20eebf22fc94befaca3f779966e10
Author: John Darrington <address@hidden>
Date: Mon Feb 13 09:15:54 2017 +0100
installer: Infer likely entries for user accounts from the gecos field.
* gnu/system/installer/user-edit.scm (user-edit-page-init): Add a
callback expression to the form constructor.
---
gnu/system/installer/user-edit.scm | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/gnu/system/installer/user-edit.scm
b/gnu/system/installer/user-edit.scm
index 23c1587..7adf88a 100644
--- a/gnu/system/installer/user-edit.scm
+++ b/gnu/system/installer/user-edit.scm
@@ -129,8 +129,29 @@
(getmaxx (inner pr))
(getmaxy text-window) 0 #:panel #f))
- (form (make-form (my-fields))))
-
+ (form (make-form (my-fields)
+ (lambda (frm)
+ ;; Infer the most likely desired values of the
+ ;; name and home fields from the other field values
+ (let* ((f (get-current-field frm))
+ (fv (form-get-value frm (field-symbol f)))
+ (brk (string-index fv #\space))
+ (first
+ (and brk
+ (string-map char-downcase
+ (string-take fv brk)))))
+ (cond ((eq? (field-symbol f) 'comment)
+ (when first
+ (form-set-value! frm 'name first)
+ (form-set-value! frm 'home
+ (string-append
"/home/"
+
first))))
+ ((eq? (field-symbol f) 'name)
+ (form-set-value! frm 'home
+ (string-append
+ "/home/"
+ (form-get-value
+ frm 'name))))))))))
(page-set-datum! p 'navigation nav)
(let ((acc (page-datum p 'account)))