From patchwork Tue Jan 29 15:37:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christopher Baines X-Patchwork-Id: 917 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 7E97016AFF; Tue, 29 Jan 2019 16:01:08 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,UNPARSEABLE_RELAY, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id E9EBD16AF9 for ; Tue, 29 Jan 2019 16:01:07 +0000 (GMT) Received: from localhost ([127.0.0.1]:51580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goVox-0006Ld-Ea for patchwork@mira.cbaines.net; Tue, 29 Jan 2019 11:01:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33801) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goVh5-0006Re-RI for guix-patches@gnu.org; Tue, 29 Jan 2019 10:53:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1goVSc-00006m-MY for guix-patches@gnu.org; Tue, 29 Jan 2019 10:38:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:51433) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1goVSc-00006c-Ig for guix-patches@gnu.org; Tue, 29 Jan 2019 10:38:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1goVSc-0003Xm-FG for guix-patches@gnu.org; Tue, 29 Jan 2019 10:38:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#34246] [PATCH 2/3] services: Improve the upower-service-type. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 29 Jan 2019 15:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34246 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 34246@debbugs.gnu.org Received: via spool by 34246-submit@debbugs.gnu.org id=B34246.154877627313594 (code B ref 34246); Tue, 29 Jan 2019 15:38:02 +0000 Received: (at 34246) by debbugs.gnu.org; 29 Jan 2019 15:37:53 +0000 Received: from localhost ([127.0.0.1]:50711 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1goVSS-0003XA-Lt for submit@debbugs.gnu.org; Tue, 29 Jan 2019 10:37:53 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:60116 helo=mira.cbaines.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1goVSQ-0003Wj-Od for 34246@debbugs.gnu.org; Tue, 29 Jan 2019 10:37:51 -0500 Received: from localhost (cpc102582-walt20-2-0-cust14.13-2.cable.virginm.net [86.27.34.15]) by mira.cbaines.net (Postfix) with ESMTPSA id 8FC0D16AFA for <34246@debbugs.gnu.org>; Tue, 29 Jan 2019 15:37:49 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id c36970df for <34246@debbugs.gnu.org>; Tue, 29 Jan 2019 15:37:49 +0000 (UTC) From: Christopher Baines Date: Tue, 29 Jan 2019 15:37:48 +0000 Message-Id: <20190129153749.10830-2-mail@cbaines.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129153749.10830-1-mail@cbaines.net> References: <877eenqy8f.fsf@cbaines.net> <20190129153749.10830-1-mail@cbaines.net> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Add a description and default value. Switch the documentation to mention the service-type and the configuration record, rather than the upower-service procedure. * gnu/services/desktop.scm (upower-service-type)[description, default-value]: Define these fields. (%desktop-services): Change (upower-service) to (service upower-service-type). * doc/guix.texi (Desktop Services): Update the upower service documentation. --- doc/guix.texi | 92 ++++++++++++++++++++++++++++++++-------- gnu/services/desktop.scm | 10 ++++- 2 files changed, 82 insertions(+), 20 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 972a6a7762..2ff120d5a3 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -34,6 +34,7 @@ Copyright @copyright{} 2016, 2017 Nils Gillmann@* Copyright @copyright{} 2016, 2017, 2018 Jan Nieuwenhuizen@* Copyright @copyright{} 2016 Julien Lepiller@* Copyright @copyright{} 2016 Alex ter Weele@* +Copyright @copyright{} 2016, 2017, 2018, 2019 Christopher Baines@* Copyright @copyright{} 2017, 2018 Clément Lassieur@* Copyright @copyright{} 2017, 2018 Mathieu Othacehe@* Copyright @copyright{} 2017 Federico Beffa@* @@ -14230,24 +14231,79 @@ capabilities to ordinary users. For example, an ordinary user can be granted the capability to suspend the system if the user is logged in locally. @end deffn -@deffn {Scheme Procedure} upower-service [#:upower @var{upower}] @ - [#:watts-up-pro? #f] @ - [#:poll-batteries? #t] @ - [#:ignore-lid? #f] @ - [#:use-percentage-for-policy? #f] @ - [#:percentage-low 10] @ - [#:percentage-critical 3] @ - [#:percentage-action 2] @ - [#:time-low 1200] @ - [#:time-critical 300] @ - [#:time-action 120] @ - [#:critical-power-action 'hybrid-sleep] -Return a service that runs @uref{http://upower.freedesktop.org/, -@command{upowerd}}, a system-wide monitor for power consumption and battery -levels, with the given configuration settings. It implements the -@code{org.freedesktop.UPower} D-Bus interface, and is notably used by -GNOME. -@end deffn +@defvr {Scheme Variable} upower-service-type +Service that runs @uref{http://upower.freedesktop.org/, @command{upowerd}}, a +system-wide monitor for power consumption and battery levels, with the given +configuration settings. + +It implements the @code{org.freedesktop.UPower} D-Bus interface, and is +notably used by GNOME. +@end defvr + +@deftp {Data Type} upower-configuration +Data type representation the configuration for UPower. + +@table @asis + +@item @code{upower} (default: @var{upower}) +Package to use for @code{upower}. + +@item @code{watts-up-pro?} (default: @code{#f}) +Enable the Watts Up Pro device. + +@item @code{poll-batteries?} (default: @code{#t}) +Enable polling the kernel for battery level changes. + +@item @code{ignore-lid?} (default: @code{#f}) +Ignore the lid state, this can be useful if it's incorrect on a device. + +@item @code{use-percentage-for-policy?} (default: @code{#f}) +Whether battery percentage based policy should be used. The default is to use +the time left, change to @code{#t} to use the percentage. + +@item @code{percentage-low} (default: @code{10}) +When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage +at which the battery is considered low. + +@item @code{percentage-critical} (default: @code{3}) +When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage +at which the battery is considered critical. + +@item @code{percentage-action} (default: @code{2}) +When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage +at which action will be taken. + +@item @code{time-low} (default: @code{1200}) +When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in +seconds at which the battery is considered low. + +@item @code{time-critical} (default: @code{300}) +When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in +seconds at which the battery is considered critical. + +@item @code{time-action} (default: @code{120}) +When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in +seconds at which action will be taken. + +@item @code{critical-power-action} (default: @code{'hybrid-sleep}) +The action taken when @code{percentage-action} or @code{time-action} is +reached (depending on the configuration of @code{use-percentage-for-policy?}). + +Possible values are: + +@itemize @bullet +@item +@code{'power-off} + +@item +@code{'hibernate} + +@item +@code{'hybrid-sleep}. +@end itemize + +@end table +@end deftp @deffn {Scheme Procedure} udisks-service [#:udisks @var{udisks}] Return a service for @uref{http://udisks.freedesktop.org/docs/latest/, diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm index f51ac4d74c..896084d2d5 100644 --- a/gnu/services/desktop.scm +++ b/gnu/services/desktop.scm @@ -272,6 +272,11 @@ is set to @var{value} when the bus daemon launches it." (define upower-service-type (let ((upower-package (compose list upower-configuration-upower))) (service-type (name 'upower) + (description + "Run @command{upowerd}}, a system-wide monitor for power +consumption and battery levels, with the given configuration settings. It +implements the @code{org.freedesktop.UPower} D-Bus interface, and is notably +used by GNOME.") (extensions (list (service-extension dbus-root-service-type upower-dbus-service) @@ -284,7 +289,8 @@ is set to @var{value} when the bus daemon launches it." ;; Make the 'upower' command visible. (service-extension profile-service-type - upower-package)))))) + upower-package))) + (default-value (upower-configuration))))) (define* (upower-service #:key (upower upower) (watts-up-pro? #f) @@ -1013,7 +1019,7 @@ as expected."))) (service wpa-supplicant-service-type) ;needed by NetworkManager (service avahi-service-type) (udisks-service) - (upower-service) + (service upower-service-type) (accountsservice-service) (colord-service) (geoclue-service)