From: Christopher Baines <mail@cbaines.net>
To: 34246@debbugs.gnu.org
Subject: [bug#34246] [PATCH 2/3] services: Improve the upower-service-type.
Date: Tue, 29 Jan 2019 15:37:48 +0000 [thread overview]
Message-ID: <20190129153749.10830-2-mail@cbaines.net> (raw)
In-Reply-To: <20190129153749.10830-1-mail@cbaines.net>
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)
--
2.20.1
next prev parent reply other threads:[~2019-01-29 15:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-29 15:28 [bug#34246] [PATCH 0/3] Improve the upower-service style Christopher Baines
2019-01-29 15:37 ` [bug#34246] [PATCH 1/3] services: Improve the upower-configuration record Christopher Baines
2019-01-29 15:37 ` Christopher Baines [this message]
2019-01-29 15:37 ` [bug#34246] [PATCH 3/3] services: desktop: Deprecate the upower-service procedure Christopher Baines
2019-02-16 21:30 ` [bug#34246] [PATCH 0/3] Improve the upower-service style Ludovic Courtès
2019-02-16 22:15 ` bug#34246: " Christopher Baines
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190129153749.10830-2-mail@cbaines.net \
--to=mail@cbaines.net \
--cc=34246@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.