From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38949) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1detzB-0002Ca-Ky for guix-patches@gnu.org; Mon, 07 Aug 2017 22:11:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1detz5-0000Wo-Bg for guix-patches@gnu.org; Mon, 07 Aug 2017 22:11:09 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:42265) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1detz5-0000Wd-77 for guix-patches@gnu.org; Mon, 07 Aug 2017 22:11:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1detz4-0004QP-I8 for guix-patches@gnu.org; Mon, 07 Aug 2017 22:11:02 -0400 Subject: [bug#28007] [PATCH] Add auto-enable? parameter to the bluetooth-service Resent-Message-ID: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38816) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1detyc-0002AP-5U for guix-patches@gnu.org; Mon, 07 Aug 2017 22:10:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1detyW-0000FF-Db for guix-patches@gnu.org; Mon, 07 Aug 2017 22:10:33 -0400 Received: from mail-it0-x22a.google.com ([2607:f8b0:4001:c0b::22a]:33083) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1detyW-0000EM-4b for guix-patches@gnu.org; Mon, 07 Aug 2017 22:10:28 -0400 Received: by mail-it0-x22a.google.com with SMTP id f16so2275529itb.0 for ; Mon, 07 Aug 2017 19:10:26 -0700 (PDT) Received: from apteryx (104-222-117-55.cpe.teksavvy.com. [104.222.117.55]) by smtp.gmail.com with ESMTPSA id k205sm261017ita.3.2017.08.07.19.10.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Aug 2017 19:10:24 -0700 (PDT) From: Maxim Cournoyer Date: Mon, 07 Aug 2017 22:10:23 -0400 Message-ID: <871somhks0.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 28007@debbugs.gnu.org --=-=-= Content-Type: text/plain Hello Guix, Here's a patch that enables bluetooth controllers automatically (power them on) without having to manually do "power on" with bluetoothctl everytime the system is rebooted. Thank you, Maxim --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-services-Add-auto-enable-parameter-to-the-bluetooth-.patch Content-Transfer-Encoding: quoted-printable >From 3631a5f6742b31ac173a6d32cb3e7074f1ce0aa5 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Mon, 7 Aug 2017 00:07:53 -0400 Subject: [PATCH] services: Add auto-enable? parameter to the bluetooth-serv= ice * gnu/services/desktop.scm (bluetooth-configuration): New record. (bluetooth-shepherd-service): Use it. (bluetooth-directory): New method. (bluetooth-service-type): Use it to extend the etc-service-type service. (bluetooth-service): Add `auto-enable?' parameter. * doc/guix.texi: Document it. --- doc/guix.texi | 11 ++++++++--- gnu/services/desktop.scm | 50 +++++++++++++++++++++++++++++++++++++++++---= ---- 2 files changed, 51 insertions(+), 10 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 6b4b19d0c..63186f6ab 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -39,6 +39,7 @@ Copyright @copyright{} 2017 humanitiesNerd@* Copyright @copyright{} 2017 Christopher Allan Webber@* Copyright @copyright{} 2017 Marius Bakke@* Copyright @copyright{} 2017 Hartmut Goebel +Copyright @copyright{} 2017 Maxim Cournoyer@* =20 Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -11712,9 +11713,13 @@ location databases. See web site} for more information. @end deffn =20 -@deffn {Scheme Procedure} bluetooth-service [#:bluez @var{bluez}] -Return a service that runs the @command{bluetoothd} daemon, which manages -all the Bluetooth devices and provides a number of D-Bus interfaces. +@deffn {Scheme Procedure} bluetooth-service [#:bluez @var{bluez}] @ + [@w{#:auto-enable? #f}] +Return a service that runs the @command{bluetoothd} daemon, which +manages all the Bluetooth devices and provides a number of D-Bus +interfaces. When AUTO-ENABLE? is true, the bluetooth controller is +powered automatically at boot, which can be useful when using a +bluetooth keyboard or mouse. =20 Users need to be in the @code{lp} group to access the D-Bus service. @end deffn diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm index 50a561bf5..8b6c2793c 100644 --- a/gnu/services/desktop.scm +++ b/gnu/services/desktop.scm @@ -3,6 +3,7 @@ ;;; Copyright =C2=A9 2015 Andy Wingo ;;; Copyright =C2=A9 2015 Mark H Weaver ;;; Copyright =C2=A9 2016 Sou Bunnbu +;;; Copyright =C2=A9 2017 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -381,32 +382,67 @@ site} for more information." ;;; Bluetooth. ;;; =20 -(define (bluetooth-shepherd-service bluez) +(define-record-type* + bluetooth-configuration make-bluetooth-configuration + bluetooth-configuration? + (bluez bluetooth-configuration-bluez (default bluez)) + (auto-enable? bluetooth-configuration-auto-enable? (default #f))) + +(define (bluetooth-configuration-file config) + "Return a configuration file for the systemd bluetooth service, as a str= ing." + (string-append + "[Policy]\n" + "AutoEnable=3D" (bool (bluetooth-configuration-auto-enable? + config)))) + +(define (bluetooth-directory config) + (computed-file "etc-bluetooth" + #~(begin + (mkdir #$output) + (chdir #$output) + (call-with-output-file "main.conf" + (lambda (port) + (display #$(bluetooth-configuration-file config) + port)))))) + +(define (bluetooth-shepherd-service config) "Return a shepherd service for @command{bluetoothd}." (shepherd-service (provision '(bluetooth)) (requirement '(dbus-system udev)) (documentation "Run the bluetoothd daemon.") (start #~(make-forkexec-constructor - (string-append #$bluez "/libexec/bluetooth/bluetoothd"))) + (string-append #$(bluetooth-configuration-bluez config) + "/libexec/bluetooth/bluetoothd"))) (stop #~(make-kill-destructor)))) =20 (define bluetooth-service-type (service-type (name 'bluetooth) (extensions - (list (service-extension dbus-root-service-type list) - (service-extension udev-service-type list) + (list (service-extension dbus-root-service-type + (compose list bluetooth-configuration-bluez)) + (service-extension udev-service-type + (compose list bluetooth-configuration-bluez)) + (service-extension etc-service-type + (lambda (config) + `(("bluetooth" + ,(bluetooth-directory config))))) (service-extension shepherd-root-service-type (compose list bluetooth-shepherd-service)))))) =20 -(define* (bluetooth-service #:key (bluez bluez)) +(define* (bluetooth-service #:key (bluez bluez) (auto-enable? #f)) "Return a service that runs the @command{bluetoothd} daemon, which manag= es -all the Bluetooth devices and provides a number of D-Bus interfaces. +all the Bluetooth devices and provides a number of D-Bus interfaces. When +AUTO-ENABLE? is true, the bluetooth controller is powered automatically at +boot. =20 Users need to be in the @code{lp} group to access the D-Bus service. " - (service bluetooth-service-type bluez)) + (service bluetooth-service-type + (bluetooth-configuration + (bluez bluez) + (auto-enable? auto-enable?)))) =20 ;;; --=20 2.13.1 --=-=-=--