[bug#34067] Add input-wacom/inputattach

Message ID 87mult44s4.fsf@yahoo.de
State Accepted
Headers show
Series [bug#34067] Add input-wacom/inputattach | expand

Checks

Context Check Description
cbaines/applying patch fail Apply failed

Commit Message

Tim Gesthuizen March 17, 2019, 8:36 p.m. UTC
Hi Ludo,
sorry for the long delay!

For now I guess it would be the best to not package the actual driver
and rely on the one that is merged into linux-libre.  I reduced the
patches to only add inputattach and the service type for it.

Tim.

Comments

Ludovic Courtès March 18, 2019, 9:24 a.m. UTC | #1
Hi Tim,

Tim Gesthuizen <tim.gesthuizen@yahoo.de> skribis:

> For now I guess it would be the best to not package the actual driver
> and rely on the one that is merged into linux-libre.  I reduced the
> patches to only add inputattach and the service type for it.

Sounds good!

I applied both patches and expounded a bit the documentation in a
followup commit.

Thank you!

Ludo’.

Patch

From 2dffbe48072e0281651a5200d75c7783de4eacbd Mon Sep 17 00:00:00 2001
From: Tim Gesthuizen <tim.gesthuizen@yahoo.de>
Date: Sat, 5 Jan 2019 23:28:18 +0100
Subject: [PATCH 2/2] gnu: Add inputattach service

Add a service that runs inputattach as a daemon to translate events from
serial ports.

* gnu/services/desktop.scm (<inputattach-configuration>): New record type.
* gnu/services/desktop.scm (inputattach-service-type): New service type.
* doc/guix.texi (Miscellaneous Services): Add inputattach Service
  subsubheading.
---
 doc/guix.texi            | 16 ++++++++++++++
 gnu/services/desktop.scm | 46 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index 9fb5cff06d..38d5daccd7 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -22306,6 +22306,22 @@  that enables sharing the clipboard with a vm and setting the guest display
 resolution when the graphical console window resizes.
 @end deffn
 
+@cindex inputattach
+@subsubheading inputattach Service
+
+@deftp {Data Type} inputattach-configuration
+@table @asis
+@item @code{device-type} The type of device to connect to.
+@item @code{device} The device file to connect to the device.
+@item @code{log-file} The file to log messages to.
+@end table
+@end deftp
+
+@deffn {Scheme Procedure} inputattach-service-type
+Return a service that runs inputattach on a device and
+dispatches events from it.
+@end deffn
+
 @subsection Dictionary Services
 @cindex dictionary
 The @code{(gnu services dict)} module provides the following service:
diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm
index ce63969dc8..16687236eb 100644
--- a/gnu/services/desktop.scm
+++ b/gnu/services/desktop.scm
@@ -8,6 +8,7 @@ 
 ;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2017, 2019 Christopher Baines <mail@cbaines.net>
+;;; Copyright © 2019 Tim Gesthuizen <tim.gesthuizen@yahoo.de>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -123,6 +124,10 @@ 
             enlightenment-desktop-configuration?
             enlightenment-desktop-service-type
 
+            inputattach-configuration
+            inputattach-configuration?
+            inputattach-service-type
+
             %desktop-services))
 
 ;;; Commentary:
@@ -1015,6 +1020,47 @@  thumbnails and makes setuid the programs which enlightenment needs to function
 as expected.")))
 
 
+;;;
+;;; inputattach-service-type
+;;;
+
+(define-record-type* <inputattach-configuration>
+  inputattach-configuration
+  make-inputattach-configuration
+  inputattach-configuration?
+  (device-type inputattach-configuration-devicetype
+               (default "wacom"))
+  (device inputattach-configuration-device
+          (default "/dev/ttyS0"))
+  (log-file inputattach-configuration-log-file
+            (default #f)))
+
+(define inputattach-shepherd-service
+  (match-lambda
+    (($ <inputattach-configuration> type device log-file)
+     (list (shepherd-service
+            (provision '(inputattach))
+            (requirement '(udev))
+            (documentation "inputattach daemon")
+            (start #~(make-forkexec-constructor
+                      (list (string-append #$inputattach
+                                           "/bin/inputattach")
+                            (string-append "--" #$type)
+                            #$device)
+                      #:log-file #$log-file))
+            (stop #~(make-kill-destructor)))))))
+
+(define inputattach-service-type
+  (service-type
+   (name 'inputattach)
+   (extensions
+    (list (service-extension shepherd-root-service-type
+                             inputattach-shepherd-service)))
+   (default-value (inputattach-configuration))
+   (description "Return a service that runs inputattach on a device and
+dispatches events from it.")))
+
+
 ;;;
 ;;; The default set of desktop services.
 ;;;
-- 
2.21.0