unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#60791] [PATCH] gnu: services: Add joycond-service.
@ 2023-01-13 22:12 Thompson, David
  2023-01-13 22:46 ` Bruno Victal
  0 siblings, 1 reply; 5+ messages in thread
From: Thompson, David @ 2023-01-13 22:12 UTC (permalink / raw)
  To: 60791

[-- Attachment #1: Type: text/plain, Size: 232 bytes --]

Hello Guix,

Joycond is a handy daemon for pairing bluetooth controllers made by
Nintendo. Someone already did the hard work of packaging it, so I
added this simple service to make it easy to use as a system service.

WDYT?

- Dave

[-- Attachment #2: 0001-gnu-services-Add-joycond-service.patch --]
[-- Type: text/x-patch, Size: 3154 bytes --]

From 247ce9cd302d3ff196eae662d27f5a37ac6ce376 Mon Sep 17 00:00:00 2001
From: David Thompson <dthompson2@worcester.edu>
Date: Fri, 13 Jan 2023 17:04:21 -0500
Subject: [PATCH] gnu: services: Add joycond-service.

* gnu/services/games.scm (<joycond-configuration>): New record type.
(joycond-configuration, joycond-configuration?, joycond-configuration-joycond,
joycond-shepherd-service): New procedures.
(joycond-service-type): New variable.
* doc/guix.texi (Game Services): Document it.
---
 doc/guix.texi          | 19 +++++++++++++++++++
 gnu/services/games.scm | 37 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 751d0957d8..4aec5895d2 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -36277,6 +36277,25 @@ like to serve.
 @node Game Services
 @subsection Game Services
 
+@subsubheading Joycond service
+@cindex joycond
+The joycond service allows the pairing of Nintendo joycon game
+controllers over Bluetooth. (@pxref{Desktop Services} for setting up
+Bluetooth.)
+
+@deftp {Data Type} joycond-configuration
+Data type representing the configuration of @command{joycond}.
+
+@table @asis
+@item @code{joycond} (default: @code{joycond})
+The joycond package to use.
+@end table
+@end deftp
+
+@defvar {Scheme Variable} joycond-service-type
+Service type for the joycond service.
+@end defvar
+
 @subsubheading The Battle for Wesnoth Service
 @cindex wesnothd
 @uref{https://wesnoth.org, The Battle for Wesnoth} is a fantasy, turn
diff --git a/gnu/services/games.scm b/gnu/services/games.scm
index 6c2af44b49..adccddfb99 100644
--- a/gnu/services/games.scm
+++ b/gnu/services/games.scm
@@ -30,10 +30,45 @@ (define-module (gnu services games)
   #:use-module (guix modules)
   #:use-module (guix records)
   #:use-module (ice-9 match)
-  #:export (wesnothd-configuration
+  #:export (joycond-configuration
+            joycond-configuration?
+            joycond-configuration-joycond
+            joycond-service-type
+
+            wesnothd-configuration
             wesnothd-configuration?
             wesnothd-service-type))
 
+;;;
+;;; Joycond
+;;;
+
+(define-record-type* <joycond-configuration>
+  joycond-configuration make-joycond-configuration
+  joycond-configuration?
+  (joycond joycond-configuration-joycond (default joycond)))
+
+(define (joycond-shepherd-service config)
+  (let ((joycond (joycond-configuration-joycond config)))
+    (list (shepherd-service
+           (documentation "Run joycond.")
+           (provision '(joycond))
+           (requirement '(bluetooth))
+           (start #~(make-forkexec-constructor
+                     (list #$(file-append joycond "/bin/joycond"))))
+           (stop #~(make-kill-destructor))))))
+
+(define joycond-service-type
+  (service-type
+   (name 'joycond)
+   (description
+    "Run @command{joycond} for pairing Nintendo joycons via Bluetooth.")
+   (extensions
+    (list (service-extension shepherd-root-service-type
+                             joycond-shepherd-service)))
+   (default-value (joycond-configuration))))
+
+\f
 ;;;
 ;;; The Battle for Wesnoth server
 ;;;
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [bug#60791] [PATCH] gnu: services: Add joycond-service.
  2023-01-13 22:12 [bug#60791] [PATCH] gnu: services: Add joycond-service Thompson, David
@ 2023-01-13 22:46 ` Bruno Victal
  2023-01-13 23:50   ` Thompson, David
  0 siblings, 1 reply; 5+ messages in thread
From: Bruno Victal @ 2023-01-13 22:46 UTC (permalink / raw)
  To: 60791; +Cc: dthompson2

Hi,

--8<---------------cut here---------------start------------->8---
+@defvar {Scheme Variable} joycond-service-type
+Service type for the joycond service.
+@end defvar
--8<---------------cut here---------------end--------------->8---

Should be `@defvar joycond-service-type'.

--8<---------------cut here---------------start------------->8---
+(define-record-type* <joycond-configuration>
+  joycond-configuration make-joycond-configuration
+  joycond-configuration?
+  (joycond joycond-configuration-joycond (default joycond)))
--8<---------------cut here---------------end--------------->8---

This could be replaced with define-configuration/no-serialization since
the only field here is a package / file-like object. (see [1], [2] for examples)
I'd prefer the field be called 'package' here. 

--8<---------------cut here---------------start------------->8---
+(define (joycond-shepherd-service config)
+  (let ((joycond (joycond-configuration-joycond config)))
+    (list (shepherd-service
+           (documentation "Run joycond.")
+           (provision '(joycond))
+           (requirement '(bluetooth))
+           (start #~(make-forkexec-constructor
+                     (list #$(file-append joycond "/bin/joycond"))))
+           (stop #~(make-kill-destructor))))))
--8<---------------cut here---------------end--------------->8---

You might prefer match-record here but this is okay as well.


[1]: https://issues.guix.gnu.org/60788
[2]: ddclient-configuration in gnu/services/dns.scm


Cheers,
Bruno




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [bug#60791] [PATCH] gnu: services: Add joycond-service.
  2023-01-13 22:46 ` Bruno Victal
@ 2023-01-13 23:50   ` Thompson, David
  2023-01-14  4:47     ` Bruno Victal
  0 siblings, 1 reply; 5+ messages in thread
From: Thompson, David @ 2023-01-13 23:50 UTC (permalink / raw)
  To: mirai; +Cc: 60791

[-- Attachment #1: Type: text/plain, Size: 2085 bytes --]

Hi Bruno,

Thanks for the review!

On Fri, Jan 13, 2023 at 5:46 PM Bruno Victal <mirai@makinata.eu> wrote:
>
> Hi,
>
> --8<---------------cut here---------------start------------->8---
> +@defvar {Scheme Variable} joycond-service-type
> +Service type for the joycond service.
> +@end defvar
> --8<---------------cut here---------------end--------------->8---
>
> Should be `@defvar joycond-service-type'.

Oh, okay. Guess I missed that change in convention.  There's lots of
'@defvar {Scheme Variable}' in the manual.

> --8<---------------cut here---------------start------------->8---
> +(define-record-type* <joycond-configuration>
> +  joycond-configuration make-joycond-configuration
> +  joycond-configuration?
> +  (joycond joycond-configuration-joycond (default joycond)))
> --8<---------------cut here---------------end--------------->8---
>
> This could be replaced with define-configuration/no-serialization since
> the only field here is a package / file-like object. (see [1], [2] for examples)
> I'd prefer the field be called 'package' here.

Ahhhh unhygienic macros! Not a fan but I see that this macro is the
preferred thing these days so okay, changed!  I also prefer the field
to be called 'package' so I've changed it! When I looked around at
some other services they used the package name as the field name so I
followed their lead.

> --8<---------------cut here---------------start------------->8---
> +(define (joycond-shepherd-service config)
> +  (let ((joycond (joycond-configuration-joycond config)))
> +    (list (shepherd-service
> +           (documentation "Run joycond.")
> +           (provision '(joycond))
> +           (requirement '(bluetooth))
> +           (start #~(make-forkexec-constructor
> +                     (list #$(file-append joycond "/bin/joycond"))))
> +           (stop #~(make-kill-destructor))))))
> --8<---------------cut here---------------end--------------->8---
>
> You might prefer match-record here but this is okay as well.

If I was destructuring many record fields I'd use it.

Updated patch attached.

Thanks!

- Dave

[-- Attachment #2: 0001-gnu-services-Add-joycond-service.patch --]
[-- Type: application/x-patch, Size: 3445 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [bug#60791] [PATCH] gnu: services: Add joycond-service.
  2023-01-13 23:50   ` Thompson, David
@ 2023-01-14  4:47     ` Bruno Victal
  2023-01-14 13:00       ` bug#60791: " Thompson, David
  0 siblings, 1 reply; 5+ messages in thread
From: Bruno Victal @ 2023-01-14  4:47 UTC (permalink / raw)
  To: Thompson, David; +Cc: 60791

--8<---------------cut here---------------start------------->8---
joycond-configuration-joycond
--8<---------------cut here---------------end--------------->8---

Doesn't need to be exported, commit message could be amended as well.


--8<---------------cut here---------------start------------->8---
+@table @asis
+@item @code{joycond} (default: @code{joycond})
+The joycond package to use.
+@end table
+@end deftp
--8<---------------cut here---------------end--------------->8---

@code should be updated to the new `package' field name.


Overall LTGM.


Cheers,
Bruno




^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#60791: [PATCH] gnu: services: Add joycond-service.
  2023-01-14  4:47     ` Bruno Victal
@ 2023-01-14 13:00       ` Thompson, David
  0 siblings, 0 replies; 5+ messages in thread
From: Thompson, David @ 2023-01-14 13:00 UTC (permalink / raw)
  To: Bruno Victal; +Cc: 60791-done

On Fri, Jan 13, 2023 at 11:47 PM Bruno Victal <mirai@makinata.eu> wrote:
>
> --8<---------------cut here---------------start------------->8---
> joycond-configuration-joycond
> --8<---------------cut here---------------end--------------->8---
>
> Doesn't need to be exported, commit message could be amended as well.
>
>
> --8<---------------cut here---------------start------------->8---
> +@table @asis
> +@item @code{joycond} (default: @code{joycond})
> +The joycond package to use.
> +@end table
> +@end deftp
> --8<---------------cut here---------------end--------------->8---
>
> @code should be updated to the new `package' field name.
>
>
> Overall LTGM.

Thanks for catching my silly late-evening fixup oversights.  Fixed all
of that and pushed!

- Dave




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-01-14 13:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-13 22:12 [bug#60791] [PATCH] gnu: services: Add joycond-service Thompson, David
2023-01-13 22:46 ` Bruno Victal
2023-01-13 23:50   ` Thompson, David
2023-01-14  4:47     ` Bruno Victal
2023-01-14 13:00       ` bug#60791: " Thompson, David

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).