aboutsummaryrefslogtreecommitdiff
path: root/gnu/services
diff options
context:
space:
mode:
authorDariqq <dariqq@posteo.net>2024-05-02 15:37:56 +0000
committerChristopher Baines <mail@cbaines.net>2024-05-15 20:58:03 +0100
commitd0ad4f557fc8b9d105877f2ef4de0ce12c5c9566 (patch)
tree20612832b13d0f32a97dc130a9020168c0a75a02 /gnu/services
parent558e2b07ea0229453a8436b6632198ad2ef2126f (diff)
downloadguix-d0ad4f557fc8b9d105877f2ef4de0ce12c5c9566.tar.gz
guix-d0ad4f557fc8b9d105877f2ef4de0ce12c5c9566.zip
gnu: services: Add power-profiles-daemon-service-type.
* 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 Signed-off-by: Christopher Baines <mail@cbaines.net>
Diffstat (limited to 'gnu/services')
-rw-r--r--gnu/services/pm.scm60
1 files changed, 59 insertions, 1 deletions
diff --git a/gnu/services/pm.scm b/gnu/services/pm.scm
index 3daf484cc1..47f0bf7812 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,75 @@
#: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