1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 Alex Kost <alezost@gmail.com>
3 ;;; Copyright © 2015, 2016, 2022 Ludovic Courtès <ludo@gnu.org>
5 ;;; This file is part of GNU Guix.
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20 (define-module (gnu services lirc)
21 #:use-module (gnu services)
22 #:use-module (gnu services shepherd)
23 #:use-module (gnu packages lirc)
24 #:use-module (guix gexp)
25 #:use-module (guix records)
26 #:use-module (ice-9 match)
27 #:export (lirc-configuration
38 (define-record-type* <lirc-configuration>
39 lirc-configuration make-lirc-configuration
41 (lirc lirc-configuration-lirc ;file-like
43 (device lirc-configuration-device) ;string
44 (driver lirc-configuration-driver) ;string
45 (config-file lirc-configuration-file) ;string | file-like object
46 (extra-options lirc-configuration-options ;list of strings
49 (define %lirc-activation
51 (use-modules (guix build utils))
52 (mkdir-p "/var/run/lirc")))
54 (define lirc-shepherd-service
56 (($ <lirc-configuration> lirc device driver config-file options)
57 (list (shepherd-service
59 (documentation "Run the LIRC daemon.")
60 (requirement '(user-processes))
61 (start #~(make-forkexec-constructor
62 (list (string-append #$lirc "/sbin/lircd")
65 #~("--device" #$device)
68 #~("--driver" #$driver)
74 (stop #~(make-kill-destructor)))))))
76 (define lirc-service-type
77 (service-type (name 'lirc)
79 (list (service-extension shepherd-root-service-type
80 lirc-shepherd-service)
81 (service-extension activation-service-type
82 (const %lirc-activation))))
83 (description "Run LIRC, a daemon that decodes infrared signals
84 from remote controls.")))
86 (define* (lirc-service #:key (lirc lirc)
87 device driver config-file
89 "Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that
90 decodes infrared signals from remote controls.
92 The daemon will use specified @var{device}, @var{driver} and
93 @var{config-file} (configuration file name).
95 Finally, @var{extra-options} is a list of additional command-line options
96 passed to @command{lircd}."
97 (service lirc-service-type
100 (device device) (driver driver)
101 (config-file config-file)
102 (extra-options extra-options))))
104 ;;; lirc.scm ends here