Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / services / lirc.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 Alex Kost <alezost@gmail.com>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
10 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19 (define-module (gnu services lirc)
20 #:use-module (gnu services)
21 #:use-module (gnu packages lirc)
22 #:use-module (guix monads)
23 #:use-module (guix store)
24 #:use-module (guix gexp)
25 #:export (lirc-service))
26
27 ;;; Commentary:
28 ;;;
29 ;;; LIRC services.
30 ;;;
31 ;;; Code:
32
33 (define* (lirc-service #:key (lirc lirc)
34 device driver config-file
35 (extra-options '()))
36 "Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that
37 decodes infrared signals from remote controls.
38
39 The daemon will use specified @var{device}, @var{driver} and
40 @var{config-file} (configuration file name).
41
42 Finally, @var{extra-options} is a list of additional command-line options
43 passed to @command{lircd}."
44 (with-monad %store-monad
45 (return
46 (service
47 (provision '(lircd))
48 (documentation "Run the LIRC daemon.")
49 (requirement '(user-processes))
50 (start #~(make-forkexec-constructor
51 (list (string-append #$lirc "/sbin/lircd")
52 "--nodaemon"
53 #$@(if device
54 #~("--device" #$device)
55 #~())
56 #$@(if driver
57 #~("--driver" #$driver)
58 #~())
59 #$@(if config-file
60 #~(#$config-file)
61 #~())
62 #$@extra-options)))
63 (stop #~(make-kill-destructor))
64 (activate #~(begin
65 (use-modules (guix build utils))
66 (mkdir-p "/var/run/lirc")))))))
67
68 ;;; lirc.scm ends here