doc: Replace references to 'dmd' with 'shepherd'.
[jackhill/guix/guix.git] / gnu / services / desktop.scm
CommitLineData
fe1a39d3
LC
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2014, 2015 Ludovic Courtès <ludo@gnu.org>
3;;; Copyright © 2015 Andy Wingo <wingo@igalia.com>
4307c476 4;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
fe1a39d3
LC
5;;;
6;;; This file is part of GNU Guix.
7;;;
8;;; GNU Guix is free software; you can redistribute it and/or modify it
9;;; under the terms of the GNU General Public License as published by
10;;; the Free Software Foundation; either version 3 of the License, or (at
11;;; your option) any later version.
12;;;
13;;; GNU Guix is distributed in the hope that it will be useful, but
14;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16;;; GNU General Public License for more details.
17;;;
18;;; You should have received a copy of the GNU General Public License
19;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21(define-module (gnu services desktop)
22 #:use-module (gnu services)
0adfe95a 23 #:use-module (gnu services dmd)
4467be21 24 #:use-module (gnu services base)
0adfe95a 25 #:use-module (gnu services dbus)
4467be21
LC
26 #:use-module (gnu services avahi)
27 #:use-module (gnu services xorg)
28 #:use-module (gnu services networking)
fe1a39d3 29 #:use-module (gnu system shadow)
6e828634 30 #:use-module (gnu system pam)
fe1a39d3
LC
31 #:use-module (gnu packages glib)
32 #:use-module (gnu packages admin)
04463bb0 33 #:use-module (gnu packages freedesktop)
fe1a39d3 34 #:use-module (gnu packages gnome)
4467be21 35 #:use-module (gnu packages avahi)
0071c789 36 #:use-module (gnu packages polkit)
6726282b
LC
37 #:use-module (gnu packages xdisorg)
38 #:use-module (gnu packages suckless)
04463bb0 39 #:use-module (guix records)
0adfe95a 40 #:use-module (guix packages)
fe1a39d3
LC
41 #:use-module (guix store)
42 #:use-module (guix gexp)
0adfe95a 43 #:use-module (srfi srfi-1)
fe1a39d3 44 #:use-module (ice-9 match)
0adfe95a 45 #:export (upower-service
2b9e0a94 46 udisks-service
4467be21 47 colord-service
cee32ee4
AW
48 geoclue-application
49 %standard-geoclue-applications
50 geoclue-service
0071c789 51 polkit-service
04463bb0
AW
52 elogind-configuration
53 elogind-service
4467be21 54 %desktop-services))
fe1a39d3
LC
55
56;;; Commentary:
57;;;
58;;; This module contains service definitions for a "desktop" environment.
59;;;
60;;; Code:
61
62\f
cee32ee4
AW
63;;;
64;;; Helpers.
65;;;
66
67(define (bool value)
68 (if value "true\n" "false\n"))
69
fe1a39d3 70
0adfe95a
LC
71(define (wrapped-dbus-service service program variable value)
72 "Return a wrapper for @var{service}, a package containing a D-Bus service,
73where @var{program} is wrapped such that environment variable @var{variable}
74is set to @var{value} when the bus daemon launches it."
75 (define wrapper
76 (program-file (string-append (package-name service) "-program-wrapper")
77 #~(begin
78 (setenv #$variable #$value)
79 (apply execl (string-append #$service "/" #$program)
80 (string-append #$service "/" #$program)
81 (cdr (command-line))))))
82
83 (computed-file (string-append (package-name service) "-wrapper")
84 #~(begin
85 (use-modules (guix build utils))
86
87 (define service-directory
88 "/share/dbus-1/system-services")
89
90 (mkdir-p (dirname (string-append #$output
91 service-directory)))
92 (copy-recursively (string-append #$service
93 service-directory)
94 (string-append #$output
95 service-directory))
96 (symlink (string-append #$service "/etc") ;for etc/dbus-1
97 (string-append #$output "/etc"))
98
99 (for-each (lambda (file)
100 (substitute* file
101 (("Exec[[:blank:]]*=[[:blank:]]*([[:graph:]]+)(.*)$"
102 _ original-program arguments)
103 (string-append "Exec=" #$wrapper arguments
104 "\n"))))
105 (find-files #$output "\\.service$")))
106 #:modules '((guix build utils))))
fe1a39d3
LC
107
108\f
109;;;
110;;; Upower D-Bus service.
111;;;
112
0adfe95a
LC
113;; TODO: Export.
114(define-record-type* <upower-configuration>
115 upower-configuration make-upower-configuration
116 upower-configuration?
117 (upower upower-configuration-upower
118 (default upower))
119 (watts-up-pro? upower-configuration-watts-up-pro?)
120 (poll-batteries? upower-configuration-poll-batteries?)
121 (ignore-lid? upower-configuration-ignore-lid?)
122 (use-percentage-for-policy? upower-configuration-use-percentage-for-policy?)
123 (percentage-low upower-configuration-percentage-low)
124 (percentage-critical upower-configuration-percentage-critical)
125 (percentage-action upower-configuration-percentage-action)
126 (time-low upower-configuration-time-low)
127 (time-critical upower-configuration-time-critical)
128 (time-action upower-configuration-time-action)
129 (critical-power-action upower-configuration-critical-power-action))
130
131(define* upower-configuration-file
132 ;; Return an upower-daemon configuration file.
133 (match-lambda
134 (($ <upower-configuration> upower
135 watts-up-pro? poll-batteries? ignore-lid? use-percentage-for-policy?
136 percentage-low percentage-critical percentage-action time-low
137 time-critical time-action critical-power-action)
138 (plain-file "UPower.conf"
139 (string-append
140 "[UPower]\n"
141 "EnableWattsUpPro=" (bool watts-up-pro?)
142 "NoPollBatteries=" (bool (not poll-batteries?))
143 "IgnoreLid=" (bool ignore-lid?)
144 "UsePercentageForPolicy=" (bool use-percentage-for-policy?)
145 "PercentageLow=" (number->string percentage-low) "\n"
146 "PercentageCritical=" (number->string percentage-critical) "\n"
147 "PercentageAction=" (number->string percentage-action) "\n"
148 "TimeLow=" (number->string time-low) "\n"
149 "TimeCritical=" (number->string time-critical) "\n"
150 "TimeAction=" (number->string time-action) "\n"
151 "CriticalPowerAction=" (match critical-power-action
152 ('hybrid-sleep "HybridSleep")
153 ('hibernate "Hibernate")
154 ('power-off "PowerOff"))
155 "\n")))))
156
0adfe95a
LC
157(define %upower-activation
158 #~(begin
159 (use-modules (guix build utils))
2da4f2dd 160 (mkdir-p "/var/lib/upower")))
0adfe95a
LC
161
162(define (upower-dbus-service config)
163 (list (wrapped-dbus-service (upower-configuration-upower config)
164 "libexec/upowerd"
165 "UPOWER_CONF_FILE_NAME"
166 (upower-configuration-file config))))
167
168(define (upower-dmd-service config)
169 "Return a dmd service for UPower with CONFIG."
170 (let ((upower (upower-configuration-upower config))
171 (config (upower-configuration-file config)))
172 (list (dmd-service
173 (documentation "Run the UPower power and battery monitor.")
174 (provision '(upower-daemon))
175 (requirement '(dbus-system udev))
176
177 (start #~(make-forkexec-constructor
178 (list (string-append #$upower "/libexec/upowerd"))
179 #:environment-variables
180 (list (string-append "UPOWER_CONF_FILE_NAME="
181 #$config))))
182 (stop #~(make-kill-destructor))))))
183
184(define upower-service-type
185 (service-type (name 'upower)
186 (extensions
187 (list (service-extension dbus-root-service-type
188 upower-dbus-service)
189 (service-extension dmd-root-service-type
190 upower-dmd-service)
0adfe95a
LC
191 (service-extension activation-service-type
192 (const %upower-activation))
193 (service-extension udev-service-type
194 (compose
195 list
196 upower-configuration-upower))))))
fe1a39d3
LC
197
198(define* (upower-service #:key (upower upower)
199 (watts-up-pro? #f)
200 (poll-batteries? #t)
201 (ignore-lid? #f)
202 (use-percentage-for-policy? #f)
203 (percentage-low 10)
204 (percentage-critical 3)
205 (percentage-action 2)
206 (time-low 1200)
207 (time-critical 300)
208 (time-action 120)
209 (critical-power-action 'hybrid-sleep))
210 "Return a service that runs @uref{http://upower.freedesktop.org/,
211@command{upowerd}}, a system-wide monitor for power consumption and battery
212levels, with the given configuration settings. It implements the
213@code{org.freedesktop.UPower} D-Bus interface, and is notably used by GNOME."
0adfe95a
LC
214 (let ((config (upower-configuration
215 (watts-up-pro? watts-up-pro?)
216 (poll-batteries? poll-batteries?)
217 (ignore-lid? ignore-lid?)
218 (use-percentage-for-policy? use-percentage-for-policy?)
219 (percentage-low percentage-low)
220 (percentage-critical percentage-critical)
221 (percentage-action percentage-action)
222 (time-low time-low)
223 (time-critical time-critical)
224 (time-action time-action)
225 (critical-power-action critical-power-action))))
226 (service upower-service-type config)))
fe1a39d3
LC
227
228\f
cee32ee4
AW
229;;;
230;;; GeoClue D-Bus service.
231;;;
232
0adfe95a
LC
233;; TODO: Export.
234(define-record-type* <geoclue-configuration>
235 geoclue-configuration make-geoclue-configuration
236 geoclue-configuration?
237 (geoclue geoclue-configuration-geoclue
238 (default geoclue))
239 (whitelist geoclue-configuration-whitelist)
240 (wifi-geolocation-url geoclue-configuration-wifi-geolocation-url)
241 (submit-data? geoclue-configuration-submit-data?)
242 (wifi-submission-url geoclue-configuration-wifi-submission-url)
243 (submission-nick geoclue-configuration-submission-nick)
244 (applications geoclue-configuration-applications))
245
cee32ee4
AW
246(define* (geoclue-application name #:key (allowed? #t) system? (users '()))
247 "Configure default GeoClue access permissions for an application. NAME is
248the Desktop ID of the application, without the .desktop part. If ALLOWED? is
249true, the application will have access to location information by default.
250The boolean SYSTEM? value indicates that an application is a system component
251or not. Finally USERS is a list of UIDs of all users for which this
252application is allowed location info access. An empty users list means all
253users are allowed."
254 (string-append
255 "[" name "]\n"
256 "allowed=" (bool allowed?)
257 "system=" (bool system?)
258 "users=" (string-join users ";") "\n"))
259
260(define %standard-geoclue-applications
261 (list (geoclue-application "gnome-datetime-panel" #:system? #t)
262 (geoclue-application "epiphany" #:system? #f)
263 (geoclue-application "firefox" #:system? #f)))
264
0adfe95a 265(define* (geoclue-configuration-file config)
cee32ee4 266 "Return a geoclue configuration file."
be1c2c54
LC
267 (plain-file "geoclue.conf"
268 (string-append
269 "[agent]\n"
0adfe95a
LC
270 "whitelist="
271 (string-join (geoclue-configuration-whitelist config)
272 ";") "\n"
be1c2c54 273 "[wifi]\n"
0adfe95a
LC
274 "url=" (geoclue-configuration-wifi-geolocation-url config) "\n"
275 "submit-data=" (bool (geoclue-configuration-submit-data? config))
276 "submission-url="
277 (geoclue-configuration-wifi-submission-url config) "\n"
278 "submission-nick="
279 (geoclue-configuration-submission-nick config)
280 "\n"
281 (string-join (geoclue-configuration-applications config)
282 "\n"))))
283
284(define (geoclue-dbus-service config)
285 (list (wrapped-dbus-service (geoclue-configuration-geoclue config)
286 "libexec/geoclue"
287 "GEOCLUE_CONFIG_FILE"
288 (geoclue-configuration-file config))))
289
0adfe95a
LC
290(define %geoclue-accounts
291 (list (user-group (name "geoclue") (system? #t))
292 (user-account
293 (name "geoclue")
294 (group "geoclue")
295 (system? #t)
296 (comment "GeoClue daemon user")
297 (home-directory "/var/empty")
298 (shell "/run/current-system/profile/sbin/nologin"))))
299
300(define geoclue-service-type
301 (service-type (name 'geoclue)
302 (extensions
303 (list (service-extension dbus-root-service-type
304 geoclue-dbus-service)
0adfe95a
LC
305 (service-extension account-service-type
306 (const %geoclue-accounts))))))
cee32ee4
AW
307
308(define* (geoclue-service #:key (geoclue geoclue)
309 (whitelist '())
310 (wifi-geolocation-url
311 ;; Mozilla geolocation service:
312 "https://location.services.mozilla.com/v1/geolocate?key=geoclue")
313 (submit-data? #f)
314 (wifi-submission-url
315 "https://location.services.mozilla.com/v1/submit?key=geoclue")
316 (submission-nick "geoclue")
317 (applications %standard-geoclue-applications))
318 "Return a service that runs the @command{geoclue} location service. This
319service provides a D-Bus interface to allow applications to request access to
320a user's physical location, and optionally to add information to online
321location databases. By default, only the GNOME date-time panel and the Icecat
322and Epiphany web browsers are able to ask for the user's location, and in the
323case of Icecat and Epiphany, both will ask the user for permission first. See
324@uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the geoclue web
325site} for more information."
0adfe95a
LC
326 (service geoclue-service-type
327 (geoclue-configuration
328 (geoclue geoclue)
329 (whitelist whitelist)
330 (wifi-geolocation-url wifi-geolocation-url)
331 (submit-data? submit-data?)
332 (wifi-submission-url wifi-submission-url)
333 (submission-nick submission-nick)
334 (applications applications))))
cee32ee4
AW
335
336\f
0071c789
AW
337;;;
338;;; Polkit privilege management service.
339;;;
340
222e3319
LC
341(define-record-type* <polkit-configuration>
342 polkit-configuration make-polkit-configuration
343 polkit-configuration?
344 (polkit polkit-configuration-polkit ;<package>
345 (default polkit))
346 (actions polkit-configuration-actions ;list of <package>
347 (default '())))
348
0adfe95a
LC
349(define %polkit-accounts
350 (list (user-group (name "polkitd") (system? #t))
351 (user-account
352 (name "polkitd")
353 (group "polkitd")
354 (system? #t)
355 (comment "Polkit daemon user")
356 (home-directory "/var/empty")
357 (shell "/run/current-system/profile/sbin/nologin"))))
358
359(define %polkit-pam-services
7824d445 360 (list (unix-pam-service "polkit-1")))
0adfe95a 361
222e3319
LC
362(define (polkit-directory packages)
363 "Return a directory containing an @file{actions} and possibly a
364@file{rules.d} sub-directory, for use as @file{/etc/polkit-1}."
365 (computed-file "etc-polkit-1"
366 #~(begin
367 (use-modules (guix build union) (srfi srfi-26))
368
369 (union-build #$output
370 (map (cut string-append <>
371 "/share/polkit-1")
372 (list #$@packages))))
373 #:modules '((guix build union))))
374
375(define polkit-etc-files
376 (match-lambda
377 (($ <polkit-configuration> polkit packages)
378 `(("polkit-1" ,(polkit-directory packages))))))
379
380(define polkit-setuid-programs
381 (match-lambda
382 (($ <polkit-configuration> polkit)
383 (list #~(string-append #$polkit
eac26c3b
RW
384 "/lib/polkit-1/polkit-agent-helper-1")
385 #~(string-append #$polkit "/bin/pkexec")))))
222e3319 386
0adfe95a 387(define polkit-service-type
0adfe95a
LC
388 (service-type (name 'polkit)
389 (extensions
390 (list (service-extension account-service-type
391 (const %polkit-accounts))
392 (service-extension pam-root-service-type
393 (const %polkit-pam-services))
394 (service-extension dbus-root-service-type
222e3319
LC
395 (compose
396 list
397 polkit-configuration-polkit))
398 (service-extension etc-service-type
399 polkit-etc-files)
400 (service-extension setuid-program-service-type
401 polkit-setuid-programs)))
402
403 ;; Extensions are lists of packages that provide polkit rules
404 ;; or actions under share/polkit-1/{actions,rules.d}.
405 (compose concatenate)
406 (extend (lambda (config actions)
407 (polkit-configuration
408 (inherit config)
409 (actions
410 (append (polkit-configuration-actions config)
411 actions)))))))
0adfe95a 412
0071c789 413(define* (polkit-service #:key (polkit polkit))
222e3319
LC
414 "Return a service that runs the
415@uref{http://www.freedesktop.org/wiki/Software/polkit/, Polkit privilege
416management service}, which allows system administrators to grant access to
417privileged operations in a structured way. By querying the Polkit service, a
418privileged system component can know when it should grant additional
419capabilities to ordinary users. For example, an ordinary user can be granted
420the capability to suspend the system if the user is logged in locally."
421 (service polkit-service-type
422 (polkit-configuration (polkit polkit))))
423
424\f
425;;;
426;;; Colord D-Bus service.
427;;;
428
429(define %colord-activation
430 #~(begin
431 (use-modules (guix build utils))
432 (mkdir-p "/var/lib/colord")
433 (let ((user (getpwnam "colord")))
434 (chown "/var/lib/colord"
435 (passwd:uid user) (passwd:gid user)))))
436
437(define %colord-accounts
438 (list (user-group (name "colord") (system? #t))
439 (user-account
440 (name "colord")
441 (group "colord")
442 (system? #t)
443 (comment "colord daemon user")
444 (home-directory "/var/empty")
445 (shell #~(string-append #$shadow "/sbin/nologin")))))
446
447(define colord-service-type
448 (service-type (name 'colord)
449 (extensions
450 (list (service-extension account-service-type
451 (const %colord-accounts))
452 (service-extension activation-service-type
453 (const %colord-activation))
454
455 ;; Colord is a D-Bus service that dbus-daemon can
456 ;; activate.
457 (service-extension dbus-root-service-type list)
458
459 ;; Colord provides "color device" rules for udev.
460 (service-extension udev-service-type list)
461
462 ;; It provides polkit "actions".
463 (service-extension polkit-service-type list)))))
464
465(define* (colord-service #:key (colord colord))
466 "Return a service that runs @command{colord}, a system service with a D-Bus
467interface to manage the color profiles of input and output devices such as
468screens and scanners. It is notably used by the GNOME Color Manager graphical
469tool. See @uref{http://www.freedesktop.org/software/colord/, the colord web
470site} for more information."
471 (service colord-service-type colord))
0071c789
AW
472
473\f
2b9e0a94
LC
474;;;
475;;; UDisks.
476;;;
477
478(define-record-type* <udisks-configuration>
479 udisks-configuration make-udisks-configuration
480 udisks-configuration?
481 (udisks udisks-configuration-udisks
482 (default udisks)))
483
484(define udisks-service-type
485 (let ((udisks-package (lambda (config)
486 (list (udisks-configuration-udisks config)))))
487 (service-type (name 'udisks)
488 (extensions
489 (list (service-extension polkit-service-type
490 udisks-package)
491 (service-extension dbus-root-service-type
492 udisks-package)
493 (service-extension udev-service-type
beca0807
LC
494 udisks-package)
495
496 ;; Profile 'udisksctl' & co. in the system profile.
497 (service-extension profile-service-type
2b9e0a94
LC
498 udisks-package))))))
499
500(define* (udisks-service #:key (udisks udisks))
501 "Return a service for @uref{http://udisks.freedesktop.org/docs/latest/,
502UDisks}, a @dfn{disk management} daemon that provides user interfaces with
503notifications and ways to mount/unmount disks. Programs that talk to UDisks
504include the @command{udisksctl} command, part of UDisks, and GNOME Disks."
505 (service udisks-service-type
506 (udisks-configuration (udisks udisks))))
507
508\f
04463bb0
AW
509;;;
510;;; Elogind login and seat management service.
511;;;
512
513(define-record-type* <elogind-configuration> elogind-configuration
514 make-elogind-configuration
515 elogind-configuration
0adfe95a
LC
516 (elogind elogind-package
517 (default elogind))
04463bb0
AW
518 (kill-user-processes? elogind-kill-user-processes?
519 (default #f))
520 (kill-only-users elogind-kill-only-users
521 (default '()))
522 (kill-exclude-users elogind-kill-exclude-users
523 (default '("root")))
524 (inhibit-delay-max-seconds elogind-inhibit-delay-max-seconds
525 (default 5))
526 (handle-power-key elogind-handle-power-key
527 (default 'poweroff))
528 (handle-suspend-key elogind-handle-suspend-key
529 (default 'suspend))
530 (handle-hibernate-key elogind-handle-hibernate-key
574d9db2
MW
531 ;; (default 'hibernate)
532 ;; XXX Ignore it for now, since we don't
533 ;; yet handle resume-from-hibernation in
534 ;; our initrd.
535 (default 'ignore))
04463bb0
AW
536 (handle-lid-switch elogind-handle-lid-switch
537 (default 'suspend))
538 (handle-lid-switch-docked elogind-handle-lid-switch-docked
539 (default 'ignore))
540 (power-key-ignore-inhibited? elogind-power-key-ignore-inhibited?
541 (default #f))
542 (suspend-key-ignore-inhibited? elogind-suspend-key-ignore-inhibited?
543 (default #f))
544 (hibernate-key-ignore-inhibited? elogind-hibernate-key-ignore-inhibited?
545 (default #f))
546 (lid-switch-ignore-inhibited? elogind-lid-switch-ignore-inhibited?
547 (default #t))
548 (holdoff-timeout-seconds elogind-holdoff-timeout-seconds
549 (default 30))
550 (idle-action elogind-idle-action
551 (default 'ignore))
552 (idle-action-seconds elogind-idle-action-seconds
553 (default (* 30 60)))
554 (runtime-directory-size-percent elogind-runtime-directory-size-percent
555 (default 10))
556 (runtime-directory-size elogind-runtime-directory-size
557 (default #f))
558 (remove-ipc? elogind-remove-ipc?
559 (default #t))
560
561 (suspend-state elogind-suspend-state
562 (default '("mem" "standby" "freeze")))
563 (suspend-mode elogind-suspend-mode
564 (default '()))
565 (hibernate-state elogind-hibernate-state
566 (default '("disk")))
567 (hibernate-mode elogind-hibernate-mode
568 (default '("platform" "shutdown")))
569 (hybrid-sleep-state elogind-hybrid-sleep-state
570 (default '("disk")))
571 (hybrid-sleep-mode elogind-hybrid-sleep-mode
572 (default
573 '("suspend" "platform" "shutdown"))))
574
575(define (elogind-configuration-file config)
576 (define (yesno x)
577 (match x
578 (#t "yes")
579 (#f "no")
580 (_ (error "expected #t or #f, instead got:" x))))
581 (define char-set:user-name
582 (string->char-set "abcdefghijklmnopqrstuvwxyz0123456789_-"))
583 (define (valid-list? l pred)
584 (and-map (lambda (x) (string-every pred x)) l))
585 (define (user-name-list users)
586 (unless (valid-list? users char-set:user-name)
587 (error "invalid user list" users))
588 (string-join users " "))
589 (define (enum val allowed)
590 (unless (memq val allowed)
591 (error "invalid value" val allowed))
592 (symbol->string val))
593 (define (non-negative-integer x)
594 (unless (exact-integer? x) (error "not an integer" x))
595 (when (negative? x) (error "negative number not allowed" x))
596 (number->string x))
597 (define handle-actions
598 '(ignore poweroff reboot halt kexec suspend hibernate hybrid-sleep lock))
599 (define (handle-action x)
600 (enum x handle-actions))
601 (define (sleep-list tokens)
602 (unless (valid-list? tokens char-set:user-name)
603 (error "invalid sleep list" tokens))
604 (string-join tokens " "))
605 (define-syntax ini-file-clause
606 (syntax-rules ()
607 ((_ config (prop (parser getter)))
608 (string-append prop "=" (parser (getter config)) "\n"))
609 ((_ config str)
610 (string-append str "\n"))))
611 (define-syntax-rule (ini-file config file clause ...)
be1c2c54 612 (plain-file file (string-append (ini-file-clause config clause) ...)))
04463bb0
AW
613 (ini-file
614 config "logind.conf"
615 "[Login]"
616 ("KillUserProcesses" (yesno elogind-kill-user-processes?))
617 ("KillOnlyUsers" (user-name-list elogind-kill-only-users))
618 ("KillExcludeUsers" (user-name-list elogind-kill-exclude-users))
619 ("InhibitDelayMaxSecs" (non-negative-integer elogind-inhibit-delay-max-seconds))
620 ("HandlePowerKey" (handle-action elogind-handle-power-key))
621 ("HandleSuspendKey" (handle-action elogind-handle-suspend-key))
622 ("HandleHibernateKey" (handle-action elogind-handle-hibernate-key))
623 ("HandleLidSwitch" (handle-action elogind-handle-lid-switch))
624 ("HandleLidSwitchDocked" (handle-action elogind-handle-lid-switch-docked))
625 ("PowerKeyIgnoreInhibited" (yesno elogind-power-key-ignore-inhibited?))
626 ("SuspendKeyIgnoreInhibited" (yesno elogind-suspend-key-ignore-inhibited?))
627 ("HibernateKeyIgnoreInhibited" (yesno elogind-hibernate-key-ignore-inhibited?))
628 ("LidSwitchIgnoreInhibited" (yesno elogind-lid-switch-ignore-inhibited?))
629 ("HoldoffTimeoutSecs" (non-negative-integer elogind-holdoff-timeout-seconds))
630 ("IdleAction" (handle-action elogind-idle-action))
631 ("IdleActionSeconds" (non-negative-integer elogind-idle-action-seconds))
632 ("RuntimeDirectorySize"
633 (identity
634 (lambda (config)
635 (match (elogind-runtime-directory-size-percent config)
636 (#f (non-negative-integer (elogind-runtime-directory-size config)))
637 (percent (string-append (non-negative-integer percent) "%"))))))
638 ("RemoveIpc" (yesno elogind-remove-ipc?))
639 "[Sleep]"
640 ("SuspendState" (sleep-list elogind-suspend-state))
641 ("SuspendMode" (sleep-list elogind-suspend-mode))
642 ("HibernateState" (sleep-list elogind-hibernate-state))
643 ("HibernateMode" (sleep-list elogind-hibernate-mode))
644 ("HybridSleepState" (sleep-list elogind-hybrid-sleep-state))
645 ("HybridSleepMode" (sleep-list elogind-hybrid-sleep-mode))))
646
0adfe95a
LC
647(define (elogind-dmd-service config)
648 "Return a dmd service for elogind, using @var{config}."
26909789
LC
649 ;; TODO: We could probably rely on service activation but the '.service'
650 ;; file currently contains an erroneous 'Exec' line.
0adfe95a
LC
651 (let ((config-file (elogind-configuration-file config))
652 (elogind (elogind-package config)))
653 (list (dmd-service
654 (documentation "Run the elogind login and seat management service.")
655 (provision '(elogind))
656 (requirement '(dbus-system))
657
658 (start #~(make-forkexec-constructor
659 (list (string-append #$elogind "/libexec/elogind/elogind"))
660 #:environment-variables
661 (list (string-append "ELOGIND_CONF_FILE=" #$config-file))))
662 (stop #~(make-kill-destructor))))))
663
664(define elogind-service-type
665 (service-type (name 'elogind)
666 (extensions
667 (list (service-extension dmd-root-service-type
668 elogind-dmd-service)
669 (service-extension dbus-root-service-type
670 (compose list elogind-package))
671 (service-extension udev-service-type
672 (compose list elogind-package))
222e3319
LC
673 (service-extension polkit-service-type
674 (compose list elogind-package))
675 ;; TODO: Extend PAM with pam_elogind.so.
0adfe95a
LC
676 ))))
677
678(define* (elogind-service #:key (config (elogind-configuration)))
04463bb0
AW
679 "Return a service that runs the @command{elogind} login and seat management
680service. The @command{elogind} service integrates with PAM to allow other
681system components to know the set of logged-in users as well as their session
682types (graphical, console, remote, etc.). It can also clean up after users
683when they log out."
0adfe95a 684 (service elogind-service-type config))
04463bb0
AW
685
686\f
cee32ee4
AW
687;;;
688;;; The default set of desktop services.
689;;;
0adfe95a 690
4467be21
LC
691(define %desktop-services
692 ;; List of services typically useful for a "desktop" use case.
693 (cons* (slim-service)
694
6726282b
LC
695 ;; Screen lockers are a pretty useful thing and these are small.
696 (screen-locker-service slock)
697 (screen-locker-service xlockmore "xlock")
698
0adfe95a 699 ;; The D-Bus clique.
4467be21
LC
700 (avahi-service)
701 (wicd-service)
2b9e0a94 702 (udisks-service)
4467be21
LC
703 (upower-service)
704 (colord-service)
cee32ee4 705 (geoclue-service)
0071c789 706 (polkit-service)
04463bb0 707 (elogind-service)
0adfe95a 708 (dbus-service)
4467be21
LC
709
710 (ntp-service)
4467be21 711
0adfe95a 712 %base-services))
4467be21 713
fe1a39d3 714;;; desktop.scm ends here