| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 |
|
| 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 deprecation)
|
| 25 | #:use-module (guix gexp)
|
| 26 | #:use-module (guix records)
|
| 27 | #:use-module (ice-9 match)
|
| 28 | #:export (lirc-configuration
|
| 29 | lirc-configuation?
|
| 30 | lirc-service |
| 31 | lirc-service-type))
|
| 32 |
|
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 |
|
| 39 | (define-record-type* <lirc-configuration>
|
| 40 | lirc-configuration make-lirc-configuration
|
| 41 | lirc-configuation?
|
| 42 | (lirc lirc-configuration-lirc |
| 43 | (default lirc))
|
| 44 | (device lirc-configuration-device |
| 45 | (default #f))
|
| 46 | (driver lirc-configuration-driver |
| 47 | (default #f))
|
| 48 | (config-file lirc-configuration-file |
| 49 | (default #f))
|
| 50 | (extra-options lirc-configuration-options |
| 51 | (default '())))
|
| 52 |
|
| 53 | (define %lirc-activation
|
| 54 | #~(begin
|
| 55 | (use-modules (guix build utils))
|
| 56 | (mkdir-p "/var/run/lirc")))
|
| 57 |
|
| 58 | (define lirc-shepherd-service
|
| 59 | (match-lambda
|
| 60 | (($ <lirc-configuration> lirc device driver config-file options)
|
| 61 | (list (shepherd-service
|
| 62 | (provision '(lircd))
|
| 63 | (documentation "Run the LIRC daemon.")
|
| 64 | (requirement '(user-processes))
|
| 65 | (start #~(make-forkexec-constructor
|
| 66 | (list (string-append #$lirc "/sbin/lircd")
|
| 67 | "--nodaemon"
|
| 68 | #$@(if device
|
| 69 | #~("--device" #$device)
|
| 70 | #~())
|
| 71 | #$@(if driver
|
| 72 | #~("--driver" #$driver)
|
| 73 | #~())
|
| 74 | #$@(if config-file
|
| 75 | #~(#$config-file)
|
| 76 | #~())
|
| 77 | #$@options)))
|
| 78 | (stop #~(make-kill-destructor)))))))
|
| 79 |
|
| 80 | (define lirc-service-type
|
| 81 | (service-type (name 'lirc)
|
| 82 | (extensions
|
| 83 | (list (service-extension shepherd-root-service-type
|
| 84 | lirc-shepherd-service)
|
| 85 | (service-extension activation-service-type
|
| 86 | (const %lirc-activation))))
|
| 87 | (description "Run LIRC, a daemon that decodes infrared signals
|
| 88 | from remote controls.")
|
| 89 | (default-value (lirc-configuration))))
|
| 90 |
|
| 91 | (define-deprecated (lirc-service #:key (lirc lirc)
|
| 92 | device driver config-file
|
| 93 | (extra-options '()))
|
| 94 | lirc-service-type
|
| 95 | "Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that
|
| 96 | decodes infrared signals from remote controls.
|
| 97 |
|
| 98 | The daemon will use specified @var{device}, @var{driver} and
|
| 99 | @var{config-file} (configuration file name).
|
| 100 |
|
| 101 | Finally, @var{extra-options} is a list of additional command-line options
|
| 102 | passed to @command{lircd}."
|
| 103 | (service lirc-service-type
|
| 104 | (lirc-configuration
|
| 105 | (lirc lirc)
|
| 106 | (device device) (driver driver)
|
| 107 | (config-file config-file)
|
| 108 | (extra-options extra-options))))
|
| 109 |
|
| 110 | |