lirc.scm 4.1 KB

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