From: Dariqq <dariqq@posteo.net>
To: 70460@debbugs.gnu.org
Cc: Dariqq <dariqq@posteo.net>,
felix@alternativebit.fr,
"Florian Pelz" <pelzflorian@pelzflorian.de>,
"Ludovic Courtès" <ludo@gnu.org>
Subject: [bug#70460] [PATCH v2 3/3] gnu: services: Add power-profiles-daemon-service-type.
Date: Thu, 2 May 2024 15:37:56 +0000 [thread overview]
Message-ID: <d918418934ba19da07cd922c677a88bb68d2c31a.1714662236.git.dariqq@posteo.net> (raw)
In-Reply-To: <cover.1714662236.git.dariqq@posteo.net>
* gnu/services/pm.scm
(power-profiles-configuration): New configuration.
(power-profiles-daemon-shepherd-service): New procedure.
(power-profiles-daemon-activation): New variable.
(power-profiles-daemon-service-type): New procedure.
* doc/guix.texi (Power Management Services): Document it.
Change-Id: Ib035d993ed82eec2a43f3ba2b4c92f77e08a0fd7
---
doc/guix.texi | 40 +++++++++++++++++++++++++++++++
gnu/services/pm.scm | 57 ++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 96 insertions(+), 1 deletion(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 749d689ac1..533715fd91 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -127,6 +127,7 @@
Copyright @copyright{} 2024 Herman Rimm@*
Copyright @copyright{} 2024 Matthew Trzcinski@*
Copyright @copyright{} 2024 Richard Sent@*
+Copyright @copyright{} 2024 Dariqq@*
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -34669,6 +34670,45 @@ Continuous Integration
@node Power Management Services
@subsection Power Management Services
+@cindex power-profiles-daemon
+@subsubheading Power Profiles Daemon
+
+The @code{(gnu services pm)} module provides a Guix service definition for
+the Linux Power Profiles Daemon, which makes power profiles handling
+available over D-Bus.
+
+The available profiles consist of the default @samp{balanced} mode, a @samp{power-saver} mode
+and on supported systems a @samp{performance} mode.
+
+@quotation Important
+The @code{power-profiles-daemon} conflicts with other power management tools
+like @code{tlp}. Using both together is not recommended.
+@end quotation
+
+@defvar power-profiles-daemon-service-type
+This is the service type for the
+@uref{https://gitlab.freedesktop.org/upower/power-profiles-daemon/, Power Profiles Daemon}.
+The value for this service is a @code{power-profiles-daemon-configuration}.
+
+To enable the Power Profiles Daemon with default configuration
+add this line to your services:
+
+@lisp
+(service power-profiles-daemon-service-type)
+@end lisp
+@end defvar
+
+@deftp {Data Type} power-profiles-daemon-configuration
+Data type representing the configuration of @code{power-profiles-daemon-service-type}.
+
+@table @asis
+@item @code{power-profiles-daemon} (default: @code{power-profiles-daemon}) (type: file-like)
+Package object of power-profiles-daemon.
+
+@end table
+@end deftp
+
+
@cindex tlp
@cindex power management with TLP
@subsubheading TLP daemon
diff --git a/gnu/services/pm.scm b/gnu/services/pm.scm
index 3daf484cc1..33d2c07367 100644
--- a/gnu/services/pm.scm
+++ b/gnu/services/pm.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
+;;; Copyright © 2024 Dariqq <dariqq@posteo.net>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -21,18 +22,72 @@ (define-module (gnu services pm)
#:use-module (guix packages)
#:use-module (guix records)
#:use-module (gnu packages admin)
+ #:use-module (gnu packages freedesktop)
#:use-module (gnu packages linux)
#:use-module (gnu services)
#:use-module (gnu services base)
#:use-module (gnu services configuration)
+ #:use-module (gnu services dbus)
#:use-module (gnu services shepherd)
#:use-module (gnu system shadow)
- #:export (tlp-service-type
+ #:export (power-profiles-daemon-service-type
+ power-profiles-daemon-configuration
+
+ tlp-service-type
tlp-configuration
thermald-configuration
thermald-service-type))
+;;;
+;;; power-profiles-daemon
+;;;
+
+(define-configuration/no-serialization power-profiles-daemon-configuration
+ (power-profiles-daemon
+ (file-like power-profiles-daemon)
+ "The power-profiles-daemon package."))
+
+(define (power-profiles-daemon-shepherd-service config)
+ (match-record
+ config <power-profiles-daemon-configuration>
+ (power-profiles-daemon)
+ (list (shepherd-service (provision '(power-profiles-daemon))
+ (requirement '(dbus-system))
+ (documentation "Run the power-profiles-daemon.")
+ (start #~(make-forkexec-constructor
+ (list #$(file-append power-profiles-daemon
+ "/libexec/power-profiles-daemon"))))
+ (stop #~(make-kill-destructor))))))
+
+(define %power-profiles-daemon-activation
+ #~(begin
+ (use-modules (guix build utils))
+ (mkdir-p "/var/lib/power-profiles-daemon")))
+
+(define power-profiles-daemon-service-type
+ (let ((config->package
+ (compose list power-profiles-daemon-configuration-power-profiles-daemon)))
+ (service-type
+ (name 'power-profiles-daemon)
+ (extensions (list
+ (service-extension shepherd-root-service-type
+ power-profiles-daemon-shepherd-service)
+ (service-extension dbus-root-service-type
+ config->package)
+ (service-extension polkit-service-type
+ config->package)
+ (service-extension profile-service-type
+ config->package)
+ (service-extension activation-service-type
+ (const %power-profiles-daemon-activation))))
+ (default-value (power-profiles-daemon-configuration))
+ (description "Run the power-profiles-daemon"))))
+
+;;;
+;;; tlp
+;;;
+
(define (uglify-field-name field-name)
(let ((str (symbol->string field-name)))
(string-join (string-split
--
2.41.0
next prev parent reply other threads:[~2024-05-02 15:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-18 18:31 [bug#70460] [PATCH 0/4] Update power-profiles-daemon and add a service-type for it Dariqq
2024-05-02 15:37 ` [bug#70460] [PATCH v2 0/3] " Dariqq
2024-05-02 15:37 ` [bug#70460] [PATCH v2 1/3] gnu: power-profiles-daemon: Update to 0.21 Dariqq
2024-05-02 15:37 ` [bug#70460] [PATCH v2 2/3] gnu: power-profiles-daemon: Build gtk-docs Dariqq
2024-05-02 15:37 ` Dariqq [this message]
2024-05-25 13:29 ` [bug#70460] [PATCH v2 3/3] gnu: services: Add power-profiles-daemon-service-type Ludovic Courtès
2024-05-25 15:15 ` Dariqq
2024-05-09 8:00 ` [bug#70460] [PATCH v2 0/3] Update power-profiles-daemon and add a service-type for it Dariqq
2024-05-16 6:55 ` bug#70460: " 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=d918418934ba19da07cd922c677a88bb68d2c31a.1714662236.git.dariqq@posteo.net \
--to=dariqq@posteo.net \
--cc=70460@debbugs.gnu.org \
--cc=felix@alternativebit.fr \
--cc=ludo@gnu.org \
--cc=pelzflorian@pelzflorian.de \
/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.