Subject: [bug#40312] ([PATCH 0/3]: Add Piper and libratbag -- New patch set; minor fixes.

From: Brendan Tildesley <[email-masked]>
Date: Sun, 12 Apr 2020 15:27:03 +1000

This patch set (all attached) corrects my sloppy use of texinfo format 
in the python-evdev patch, and uses git-fetch instead of github archive 
tarballs.

I originally sent these patches in when the mailing list was down so it 
all got lost to civilization I think.

If you looking at reviewing this but have no interest in 
Piper/libratbag, at least it would be good to add python-evdev, as there 
is at least one other user that wishes to use it.

Thanks.

>From 69e46ff13c1dad0891b5402f967573ff48b2f318 Mon Sep 17 00:00:00 2001
From: Brendan Tildesley <[email-masked]>
Date: Sat, 28 Mar 2020 17:15:02 +1100
Subject: [PATCH 1/3] gnu: Add python-evdev.

* gnu/packages/linux.scm (python-evdev): New variable.
---
 gnu/packages/linux.scm | 42 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 8fec3352f3..4dc788dc98 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -28,7 +28,7 @@
 ;;; Copyright © 2017 nee <[email-masked]>
 ;;; Copyright © 2017 Dave Love <[email-masked]>
 ;;; Copyright © 2018 Pierre-Antoine Rouby <[email-masked]>
-;;; Copyright © 2018 Brendan Tildesley <[email-masked]>
+;;; Copyright © 2018, 2020 Brendan Tildesley <[email-masked]>
 ;;; Copyright © 2018 Manuel Graf <[email-masked]>
 ;;; Copyright © 2018 Pierre Langlois <[email-masked]>
 ;;; Copyright © 2018 Vasile Dumitrascu <[email-masked]>
@@ -2922,6 +2922,46 @@ time.")
 (define-public eudev-with-hwdb
   (deprecated-package "eudev-with-hwdb" eudev))
 
+(define-public python-evdev
+  (package
+    (name "python-evdev")
+    (version "1.3.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "evdev" version))
+       (sha256
+        (base32
+         "0kb3636yaw9l8xi8s184w0r0n9ic5dw3b8hx048jf9fpzss4kimi"))))
+    (build-system python-build-system)
+    (native-inputs
+     `(("kernel-headers" ,linux-libre-headers)))
+    (arguments
+     `(#:tests? #f ;; No rule for tests
+       #:phases
+       (modify-phases %standard-phases
+         (add-before 'build 'patch-patch
+           (lambda* (#:key inputs #:allow-other-keys)
+             (substitute* "setup.py"
+               (("/usr/include/linux")
+                (string-append
+                 (assoc-ref inputs "kernel-headers") "/include/linux")))
+             #t)))))
+    (home-page
+     "https://github.com/gvalkov/python-evdev")
+    (synopsis
+     "Bindings to the Linux input handling subsystem")
+    (description
+     "Python-evdev provides bindings to the generic input event
+interface in Linux.  The @code{evdev} interface serves the purpose of
+passing events generated in the kernel directly to userspace through character
+devices that are typically located in @file{/dev/input/}.
+
+This package also comes with bindings to @code{uinput}, the userspace input
+subsystem.  @code{uinput} allows userspace programs to create and handle
+input devices that can inject events directly into the input subsystem.")
+    (license license:bsd-3)))
+
 (define-public lvm2
   (package
     (name "lvm2")
-- 
2.26.0

>From 12be532513d633cd66f171dcadf251bda995b985 Mon Sep 17 00:00:00 2001
From: Brendan Tildesley <[email-masked]>
Date: Sat, 28 Mar 2020 19:08:50 +1100
Subject: [PATCH 2/3] gnu: Add libratbag.

* gnu/packages/gnome.scm (libratbag): New variable.
---
 gnu/packages/gnome.scm | 69 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 68 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
index bc78910c64..b1b4383f72 100644
--- a/gnu/packages/gnome.scm
+++ b/gnu/packages/gnome.scm
@@ -27,7 +27,7 @@
 ;;; Copyright © 2017, 2018 nee <[email-masked]>
 ;;; Copyright © 2017 Chris Marusich <[email-masked]>
 ;;; Copyright © 2017 Mohammed Sadiq <[email-masked]>
-;;; Copyright © 2017 Brendan Tildesley <[email-masked]>
+;;; Copyright © 2017, 2020 Brendan Tildesley <[email-masked]>
 ;;; Copyright © 2017, 2018 Rutger Helling <[email-masked]>
 ;;; Copyright © 2018 Jovany Leandro G.C <[email-masked]>
 ;;; Copyright © 2018 Vasile Dumitrascu <[email-masked]>
@@ -159,10 +159,12 @@
   #:use-module (gnu packages speech)
   #:use-module (gnu packages spice)
   #:use-module (gnu packages sqlite)
+  #:use-module (gnu packages swig)
   #:use-module (gnu packages ssh)
   #:use-module (gnu packages tex)
   #:use-module (gnu packages time)
   #:use-module (gnu packages tls)
+  #:use-module (gnu packages valgrind)
   #:use-module (gnu packages version-control)
   #:use-module (gnu packages video)
   #:use-module (gnu packages virtualization)
@@ -9889,3 +9891,68 @@ to.")
               license:public-domain
               ;; snowball
               license:bsd-2))))
+
+(define-public libratbag
+  (package
+    (name "libratbag")
+    (version "0.13")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/libratbag/libratbag.git")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "18y8mfr63d91278m1kcid0wvrxa1sgjs8na9af1ks2n28ssvciwq"))))
+    (build-system meson-build-system)
+    (native-inputs `(("pkg-config" ,pkg-config)
+                     ("check" ,check)
+                     ("swig" ,swig)
+                     ("valgrind" ,valgrind)))
+    (inputs `(("glib" ,glib)
+              ("json-glib" ,json-glib)
+              ("libevdev" ,libevdev)
+              ("udev" ,eudev)
+              ("libunistring" ,libunistring)
+              ("python-pygobject" ,python-pygobject)
+              ("python-evdev" ,python-evdev)
+              ("libsystemd" ,elogind)))
+    (arguments
+     `(#:configure-flags
+       (list "-Dsystemd=false"
+             "-Dlogind-provider=elogind")
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'install 'wrap
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (site (string-append
+                           "/lib/python"
+                           ,(version-major+minor (package-version python))
+                           "/site-packages"))
+                    (evdev (string-append
+                            (assoc-ref inputs "python-evdev") site))
+                    (pygo (string-append
+                           (assoc-ref inputs "python-pygobject") site))
+                    (python-wrap
+                     `("PYTHONPATH" = (,evdev ,pygo))))
+               (wrap-program (string-append out "/bin/" "ratbagctl")
+                 python-wrap)
+               #t))))))
+    (home-page "https://github.com/libratbag/libratbag")
+    (synopsis "DBus daemon and utility for configuring gaming mice")
+    (description "libratbag provides @command{ratbagd}, a DBus daemon to
+configure input devices, mainly gaming mice.  The daemon provides a generic
+way to access the various features exposed by these mice and abstracts away
+hardware-specific and kernel-specific quirks.  There is also the
+@command{ratbagctl} command line interface for configuring devices.
+
+libratbag currently supports devices from Logitech, Etekcity, GSkill, Roccat,
+Steelseries.
+
+The ratbagd dbus service can be enabled by adding the following service to
+your operating-system definition:
+(simple-service 'ratbagd dbus-root-service-type (list libratbag))
+")
+    (license license:expat)))
-- 
2.26.0

>From f4395487a19f003450793b1274af3def611a43f2 Mon Sep 17 00:00:00 2001
From: Brendan Tildesley <[email-masked]>
Date: Sat, 28 Mar 2020 19:14:45 +1100
Subject: [PATCH 3/3] gnu: Add piper.

* gnu/packages/gnome (piper): New variable.
---
 gnu/packages/gnome.scm | 61 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
index b1b4383f72..5d2144fceb 100644
--- a/gnu/packages/gnome.scm
+++ b/gnu/packages/gnome.scm
@@ -183,6 +183,7 @@
   #:use-module (guix build-system meson)
   #:use-module (guix build-system python)
   #:use-module (guix build-system trivial)
+  #:use-module (guix build python-build-system)
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module ((guix licenses) #:prefix license:)
@@ -9956,3 +9957,63 @@ your operating-system definition:
 (simple-service 'ratbagd dbus-root-service-type (list libratbag))
 ")
     (license license:expat)))
+
+(define-public piper
+  (package
+    (name "piper")
+    (version "0.4")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/libratbag/piper.git")
+             (commit version)))
+       (sha256
+        (base32
+         "17h06j8lxpbfygq8fzycl7lml4vv7r05bsyhh3gga2hp0zms4mvg"))))
+    (build-system meson-build-system)
+    (native-inputs `(("pkg-config" ,pkg-config)
+                     ("glib:bin" ,glib "bin")
+                     ("gobject-introspection" ,gobject-introspection)
+                     ("gettext" ,gettext-minimal)
+                     ("python-flake8" ,python-flake8)))
+    (inputs `(("gtk:bin" ,gtk+ "bin")
+              ("gtk" ,gtk+)
+              ("adwaita-icon-theme" ,adwaita-icon-theme)
+              ("librsvg" ,librsvg)
+              ("python-pygobject" ,python-pygobject)
+              ("python-lxml" ,python-lxml)
+              ("python-evdev" ,python-evdev)
+              ("python-pycairo" ,python-pycairo)))
+    (arguments
+     `(#:imported-modules ((guix build python-build-system)
+                           ,@%meson-build-system-modules)
+       #:modules (((guix build python-build-system) #:prefix python:)
+                  (guix build meson-build-system)
+                  (guix build utils))
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'dont-update-gtk-icon-cache
+           (lambda _
+             (substitute* "meson.build"
+               (("meson.add_install_script('meson_install.sh')") ""))
+             #t))
+         ;; TODO: Switch to wrap-script when it is fixed
+         (add-after 'install 'wrap-python
+           (assoc-ref python:%standard-phases 'wrap))
+         (add-after 'wrap-python 'wrap
+           (lambda* (#:key outputs #:allow-other-keys)
+             (wrap-program
+                 (string-append (assoc-ref outputs "out" )"/bin/piper")
+               `("GI_TYPELIB_PATH" = (,(getenv "GI_TYPELIB_PATH"))))
+             #t)))))
+    (home-page "https://github.com/libratbag/piper/")
+    (synopsis "Configure bindings and LEDs on gaming mice")
+    (description "Piper is a GTK+ application for configuring gaming mice with
+onboard configuration for key bindings via libratbag. Piper requires a
+@command{ratbagd} daemon running with root privileges. It can be run manually
+as root, but is preferably configured as a dbus service that can launch on
+demand.  This can be configured by enabling the following service, provided
+there is a dbus-service present:
+ (simple-service 'ratbagd dbus-root-service-type (list libratbag))")
+    (license license:gpl2)))
-- 
2.26.0