From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 0PgcBvc+PGPUPgEAbAwnHQ (envelope-from ) for ; Tue, 04 Oct 2022 16:11:03 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id YC8QBvc+PGPFfQEAauVa8A (envelope-from ) for ; Tue, 04 Oct 2022 16:11:03 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A7C2B21B93 for ; Tue, 4 Oct 2022 16:11:02 +0200 (CEST) Received: from localhost ([::1]:40568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ofidR-0001Ym-Ot for larch@yhetil.org; Tue, 04 Oct 2022 10:11:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40038) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ofhyo-0005Nq-LO for guix-patches@gnu.org; Tue, 04 Oct 2022 09:29:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:53863) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ofhyo-0000QW-DX for guix-patches@gnu.org; Tue, 04 Oct 2022 09:29:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ofhyo-0004NI-5f for guix-patches@gnu.org; Tue, 04 Oct 2022 09:29:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58170] [PATCH 1/1] gnu: home: Add home-batsignal-service-type. Resent-From: Andrew Tropin Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 04 Oct 2022 13:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58170 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58170@debbugs.gnu.org Cc: "\(" X-Debbugs-Original-To: "( via Guix-patches via" , 58170@debbugs.gnu.org Received: via spool by 58170-submit@debbugs.gnu.org id=B58170.166489008416730 (code B ref 58170); Tue, 04 Oct 2022 13:29:02 +0000 Received: (at 58170) by debbugs.gnu.org; 4 Oct 2022 13:28:04 +0000 Received: from localhost ([127.0.0.1]:52937 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ofhxq-0004Ll-RE for submit@debbugs.gnu.org; Tue, 04 Oct 2022 09:28:03 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:48389) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ofhxn-0004LN-Ar for 58170@debbugs.gnu.org; Tue, 04 Oct 2022 09:28:00 -0400 Received: (Authenticated sender: andrew@trop.in) by mail.gandi.net (Postfix) with ESMTPSA id 336AF60010; Tue, 4 Oct 2022 13:27:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop.in; s=gm1; t=1664890073; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=bPpFCXXTNp/VXlDsOgb3IBXQLqyzU/Fca+ImEbpgTSE=; b=hHVx6iQmCVSH3hTc4Pj2fLiMgHD6TelpVquUGmUYOAGW5gbAP7ogug/kNxPJ2qHYBbFRZL gjkPFn9Edrl1RnbZt6ks5KvA+pGV3kyHq8vifC9w5ar8/f5EXMcqRNmM9dxNZpo39H4e4G zUdE7HxeJ/PpyM2zLoYxhmQfSx8Tr3U0bOyfT5Rc8GXRYakIv3jWBh8vMsMegffT8bzId1 sW/Cqq8hIhO1NKz4jl3eo4K9WtyuWFv6wiGzS93xac75CzbWiYtPqdhwi7X5KkwCcgrrtM jmoLfNjE4RnmeC081Edh2PjWZc+LwBfvxRasnApXMXVhhBbai9+6swiJwEctIw== From: Andrew Tropin In-Reply-To: <20220929164020.9178-1-paren@disroot.org> References: <20220929163853.9019-1-paren@disroot.org> <20220929164020.9178-1-paren@disroot.org> Date: Tue, 04 Oct 2022 17:27:47 +0400 Message-ID: <87pmf74t2k.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1664892662; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=bPpFCXXTNp/VXlDsOgb3IBXQLqyzU/Fca+ImEbpgTSE=; b=OoU2Wall/TIEmK/OGeqC7IXAMtbQFwXixcRknjaFjJq+J6UtTxi9QIUFyF8xPVHXuO3XbT nIzJBzXoCQbFwtBdAq7MIzwowCSqiKLgk3hI09GfFWbsctHt4x39SQmCOUk/7BzO3MU1cn NSG5JTCRNFGfdD58SI8XMRejKp58dbrOhw+H6hExHxaGNd3hmWoGhbD/LBSdaTiN68GmXy BQMPhFZdouBx6DNkdv7sL/T84VieC1qIZdswBGkAMPbqd7dZYzyAi5MLjrcSYfrNnPXP03 aUblR4SoNmu4zTCkxyZgGYOw+MQQs5FalIS2XOpHSzjUx3Ox3iBLuySKsB7QUQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1664892662; a=rsa-sha256; cv=none; b=o2xRDEW1ejxws99joXZlLc+kZVRBN9f+tla8hERQonLW2OaVTleWQRQHGenachwDiI7G56 Nt4qBEerQFXizj1Lqo6GSoueqWaRr6/ZDZHqgygd2Ffb9Ovl0QE7JowZFN6S5auEAwWmSX IgGqhiQTmDG96jd7hU8FEj5nucrWdkPPStzqDrzuTI0jQq6jnkoZnFjiUMij5kFQzD36mH MYkRe2e9vnP/o3jkdaDASQkNiE55G6BvOe15jBZgjsWjqG6xsK4X4DEnOilpC1RtuBbL3v 7K83r8SvjD6JFZU0qH148XZf2nvoM5SCTiMluCvXePWiN3yFEgJhus7H3DuGcw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=hHVx6iQm; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 0.44 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=hHVx6iQm; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: A7C2B21B93 X-Spam-Score: 0.44 X-Migadu-Scanner: scn1.migadu.com X-TUID: +TtAKPVIZqnu --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2022-09-29 17:40, "\( via Guix-patches" via wrote: > * gnu/home/services/pm.scm (home-batsignal-service-type): New > variable. > (home-batsignal-configuration): New record type. > * doc/guix.texi: Document them. > * gnu/local.mk: Add gnu/home/services/pm.scm. > --- > doc/guix.texi | 89 ++++++++++++++++++++++-- > gnu/home/services/pm.scm | 145 +++++++++++++++++++++++++++++++++++++++ > gnu/local.mk | 2 + > 3 files changed, 230 insertions(+), 6 deletions(-) > create mode 100644 gnu/home/services/pm.scm > > diff --git a/doc/guix.texi b/doc/guix.texi > index c534574f81..081a7fb34f 100644 > --- a/doc/guix.texi > +++ b/doc/guix.texi > @@ -107,6 +107,7 @@ Copyright @copyright{} 2022 Karl Hallsby@* > Copyright @copyright{} 2022 Justin Veilleux@* > Copyright @copyright{} 2022 Reily Siegel@* > Copyright @copyright{} 2022 Simon Streit@* > +Copyright @copyright{} 2022 (@* >=20=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 > @@ -40119,12 +40120,13 @@ services)}. >=20=20 > @menu > * Essential Home Services:: Environment variables, packages, on-* scrip= ts. > -* Shells: Shells Home Services. POSIX shells, Bash, Zsh. > -* Mcron: Mcron Home Service. Scheduled User's Job Execution. > -* Shepherd: Shepherd Home Service. Managing User's Daemons. > -* SSH: Secure Shell. Setting up the secure shell cli= ent. > -* Desktop: Desktop Home Services. Services for graphical environm= ents. > -* Guix: Guix Home Services. Services for Guix. > +* Shells: Shells Home Services. POSIX shells, Bas= h, Zsh. > +* Mcron: Mcron Home Service. Scheduled User's = Job Execution. > +* Power Management: Power Management Home Services. Services for batt= ery power. > +* Shepherd: Shepherd Home Service. Managing User's D= aemons. > +* SSH: Secure Shell. Setting up the se= cure shell client. > +* Desktop: Desktop Home Services. Services for grap= hical environments. > +* Guix: Guix Home Services. Services for Guix. > @end menu > @c In addition to that Home Services can provide >=20=20 > @@ -40572,6 +40574,81 @@ specifications,, mcron, GNU@tie{}mcron}). > @end table > @end deftp >=20=20 > +@node Power Management Home Services > + > +@cindex power management > +The @code{(gnu home services pm)} module provides home services > +pertaining to battery power. > + > +@defvr {Scheme Variable} home-batsignal-service-type > +Service for @code{batsignal}, a program that monitors battery levels > +and warns the user through desktop notifications when their battery > +is getting low. You can also configure a command to be run when the > +battery level passes a point deemed ``dangerous''. This service is > +configured with the @code{home-batsignal-configuration} record. > +@end defvr > + > +@deftp {Data Type} home-batsignal-configuration > +Data type representing the configuration for batsignal. > + > +@table @asis > +@item @code{warning-level} (default: @code{15}) > +The battery level to send a warning message at. > + > +@item @code{warning-message} (default: @code{#f}) > +The message to send as a notification when the battery level reaches > +the @code{warning-level}. Setting to @code{#f} uses the default > +message. > + > +@item @code{critical-level} (default: @code{5}) > +The battery level to send a critical message at. > + > +@item @code{critical-message} (default: @code{#f}) > +The message to send as a notification when the battery level reaches > +the @code{critical-level}. Setting to @code{#f} uses the default > +message. > + > +@item @code{danger-level} (default: @code{2}) > +The battery level to run the @code{danger-command} at. > + > +@item @code{danger-command} (default: @code{#f}) > +The command to run when the battery level reaches the @code{danger-level= }. > +Setting to @code{#f} disables running the command entirely. > + > +@item @code{full-level} (default: @code{#f}) > +The battery level to send a full message at. Setting to @code{#f} > +disables sending the full message entirely. > + > +@item @code{full-message} (default: @code{#f}) > +The message to send as a notification when the battery level reaches > +the @code{full-level}. Setting to @code{#f} uses the default message. > + > +@item @code{batteries} (default: @code{'()}) > +The batteries to monitor. Setting to @code{'()} tries to find batteries > +automatically. > + > +@item @code{poll-delay} (default: @code{60}) > +The time in seconds to wait before checking the batteries again. > + > +@item @code{icon} (default: @code{#f}) > +A file-like object to use as the icon for battery notifications. Setting > +to @code{#f} disables notification icons entirely. > + > +@item @code{notifications?} (default: @code{#t}) > +Whether to send any notifications. > + > +@item @code{notifications-expire?} (default: @code{#f}) > +Whether notifications sent expire after a time. > + > +@item @code{notification-command} (default: @code{#f}) > +Command to use to send messages. Setting to @code{#f} sends a notificat= ion > +through @code{libnotify}. > + > +@item @code{ignore-missing?} (default: @code{#f}) > +Whether to ignore missing battery errors. > +@end table > +@end deftp > + > @node Shepherd Home Service > @subsection Managing User Daemons >=20=20 > diff --git a/gnu/home/services/pm.scm b/gnu/home/services/pm.scm > new file mode 100644 > index 0000000000..5f09941827 > --- /dev/null > +++ b/gnu/home/services/pm.scm > @@ -0,0 +1,145 @@ > +;;; GNU Guix --- Functional package management for GNU > +;;; Copyright =C2=A9 2022 ( > +;;; > +;;; This file is part of GNU Guix. > +;;; > +;;; GNU Guix is free software; you can redistribute it and/or modify > +;;; it under the terms of the GNU General Public License as published by > +;;; the Free Software Foundation, either version 3 of the License, or > +;;; (at your option) any later version. > +;;; > +;;; GNU Guix is distributed in the hope that it will be useful, > +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of > +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +;;; GNU General Public License for more details. > +;;; > +;;; You should have received a copy of the GNU General Public License > +;;; along with GNU Guix. If not, see . > + > +(define-module (gnu home services pm) > + #:use-module (guix gexp) > + #:use-module (guix packages) > + #:use-module (guix records) > + #:use-module (gnu home services) > + #:use-module (gnu home services shepherd) > + #:use-module (gnu packages monitoring) > + #:use-module (gnu services shepherd) > + > + #:export (home-batsignal-configuration > + home-batsignal-service-type)) > + > +;;; > +;;; batsignal > +;;; > +;;; Daemon for running commands and displaying notifications on > +;;; battery events. > +;;; > + > +(define-record-type* > + home-batsignal-configuration make-home-batsignal-configuration > + home-batsignal-configuration? > + (warning-level batsignal-warning-level ;integer > + (default 15)) > + (warning-message batsignal-warning-message ;string | #f > + (default #f)) > + (critical-level batsignal-critical-level ;integer > + (default 5)) > + (critical-message batsignal-critical-message ;string | #f > + (default #f)) > + (danger-level batsignal-danger-level ;integer > + (default 2)) > + (danger-command batsignal-danger-command ;file-like |= string | #f > + (default #f)) > + (full-level batsignal-full-level ;integer | #f > + (default #f)) > + (full-message batsignal-full-message ;string | #f > + (default #f)) > + (batteries batsignal-batteries ;list of str= ing > + (default '())) > + (poll-delay batsignal-poll-delay ;integer > + (default 60)) > + (icon batsignal-icon ;file-like |= #f > + (default #f)) > + (notifications? batsignal-notifications? ;boolean > + (default #t)) > + (notifications-expire? batsignal-notifications-expire? ;boolean > + (default #f)) > + (notification-command batsignal-notification-command ;string | #f > + (default #f)) > + (ignore-missing? batsignal-ignore-missing? ;boolean > + (default #f))) > + > +(define (home-batsignal-shepherd-services config) > + (let ((warning-level (batsignal-warning-level config)) > + (warning-message (batsignal-warning-message config)) > + (critical-level (batsignal-critical-level config)) > + (critical-message (batsignal-critical-message config)) > + (danger-level (batsignal-danger-level config)) > + (danger-command (batsignal-danger-command config)) > + (full-level (batsignal-full-level config)) > + (full-message (batsignal-full-message config)) > + (batteries (batsignal-batteries config)) > + (poll-delay (batsignal-poll-delay config)) > + (icon (batsignal-icon config)) > + (notifications? (batsignal-notifications? config)) > + (notifications-expire? (batsignal-notifications-expire? config)) > + (notification-command (batsignal-notification-command config)) > + (ignore-missing? (batsignal-ignore-missing? config))) > + (list (shepherd-service > + (provision '(batsignal)) > + (documentation "Run the batsignal battery-watching daemon.") > + (start #~(make-forkexec-constructor > + (append (list #$(file-append batsignal "/bin/batsig= nal") > + "-w" (number->string #$warning-level) > + "-c" (number->string #$critical-level) > + "-d" (number->string #$danger-level) > + "-m" (number->string #$poll-delay)) > + (if #$warning-message > + (list "-W" #$warning-message) > + (list)) > + (if #$critical-message > + (list "-C" #$critical-message) > + (list)) > + (if #$danger-command > + (list "-D" #$danger-command) > + (list)) > + (if #$full-level > + (list "-f" (number->string #$full-level= )) > + (list)) > + (if #$full-message > + (list "-F" #$full-message) > + (list)) > + (if (null? (list #$@batteries)) > + (list) > + (list "-n" (string-join (list #$@batter= ies) ","))) > + (if #$icon > + (list "-I" #$icon) > + (list)) > + (if #$notifications? > + (list) > + (list "-N")) > + (if #$notifications-expire? > + (list "-e") > + (list)) > + (if #$notification-command > + (list "-M" #$notification-command) > + (list)) > + (if #$ignore-missing? > + (list "-i") > + (list))) > + #:log-file (string-append > + (or (getenv "XDG_LOG_HOME") > + (format #f "~a/.local/var/log" > + (getenv "HOME"))) > + "/batsignal.log"))) > + (stop #~(make-kill-destructor)))))) > + > +(define home-batsignal-service-type > + (service-type > + (name 'home-batsignal) > + (extensions > + (list (service-extension home-shepherd-service-type > + home-batsignal-shepherd-services))) > + (default-value (home-batsignal-configuration)) > + (description > + "Run batsignal, a battery watching and notification daemon."))) > diff --git a/gnu/local.mk b/gnu/local.mk > index 4e982dc6e3..9ef10fcbfe 100644 > --- a/gnu/local.mk > +++ b/gnu/local.mk > @@ -54,6 +54,7 @@ > # Copyright =C2=A9 2022 muradm > # Copyright =C2=A9 2022 Hilton Chain > # Copyright =C2=A9 2022 Alex Griffin > +# Copyright =C2=A9 2022 ( > # > # This file is part of GNU Guix. > # > @@ -89,6 +90,7 @@ GNU_SYSTEM_MODULES =3D \ > %D%/home/services/symlink-manager.scm \ > %D%/home/services/fontutils.scm \ > %D%/home/services/guix.scm \ > + %D%/home/services/pm.scm \ > %D%/home/services/shells.scm \ > %D%/home/services/shepherd.scm \ > %D%/home/services/ssh.scm \ Hi! Slightly reworded commit message and fixed texinfo warning, applied, thank you! 7030f592c643360105514f9f1f923b0b6342d5e3 =2D-=20 Best regards, Andrew Tropin --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmM8NNMACgkQIgjSCVjB 3rCD3Q//X5NUF7H8gumCQZy/FCRzT8+wi9eu9mSlS0s+inr9ZrgsvBHTAyJ3BVDA BoYftQqmPTc0RAmNTB9J857P63qK4eTR8dtyyg1S0DDqmXRkHc2YwtjMIYoevgfc B8ln6kiR8sw+kGfPHH8rYQazNY4F7Q9NyC/sdtyWyS0IvOLdapywzx/ARHo0t1W4 dJ1chHB8KiIhoHJzIG45U0u8Q+UGKwtkG5gnMR9qlRX/+p85zcZlpFAjMyVJUTDt rb27rTQ/2KXtWlKgRYZaGqjpUOo5WDn8OResAC1knj8itiOKou1irw2vhYR+Z4B3 CYIXx/2L5Wx/2VaXlVYOEgW1m/vqdx/FtG3dmPtolv1QyagfYI9dmNXFyi/1kSUM kIBXdNytmvcZ/VcezOYe7x1tloWPWAoo705/gNxay+sv1yg7Wx0vinSp7YEOOtXt XJ+xt8zRpt36L0SFSiUO8YCfSPK6yxHn7DRjdJLpfAzexPe3cZvw5OnIKepHpPV5 cN5xE3wGigt5Kssu3DfhO/4ep2s/OX6SB9JrZ4o9oelAXXtj2glruvykHu51Jdo1 ryap+j2ZtUlmMJo3pnJ93nmAARniY+yXIuWv0BFbq4GqFp5RYx+V6IaDVPXgeG11 MhakMZTkm8F9zcoztNscIJgt8gNyTkmRuU6UWdai4bVupiUCsw4= =4qx4 -----END PGP SIGNATURE----- --=-=-=--