From patchwork Sun Dec 24 18:53:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "vasilii.smirnov--- via Guix-patches\" via" X-Patchwork-Id: 58040 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 78C5A27BBE2; Sun, 24 Dec 2023 19:25:25 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HTML_MESSAGE,MAILING_LIST_MULTI,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 340E627BBE9 for ; Sun, 24 Dec 2023 19:25:23 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rHU5T-0003PN-71; Sun, 24 Dec 2023 14:24:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rHTbp-0000A0-FT for guix-patches@gnu.org; Sun, 24 Dec 2023 13:53:57 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rHTbp-000765-7x for guix-patches@gnu.org; Sun, 24 Dec 2023 13:53:57 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rHTbt-0000Hc-Ur for guix-patches@gnu.org; Sun, 24 Dec 2023 13:54:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68012] [PATCH] services: Add thinkfan service. Resent-From: lgcoelho@disroot.org Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 24 Dec 2023 18:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 68012 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68012@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.17034440291068 (code B ref -1); Sun, 24 Dec 2023 18:54:01 +0000 Received: (at submit) by debbugs.gnu.org; 24 Dec 2023 18:53:49 +0000 Received: from localhost ([127.0.0.1]:53517 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rHTbg-0000H9-IO for submit@debbugs.gnu.org; Sun, 24 Dec 2023 13:53:48 -0500 Received: from lists.gnu.org ([2001:470:142::17]:57566) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rHTbe-0000Gv-Mw for submit@debbugs.gnu.org; Sun, 24 Dec 2023 13:53:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rHTbT-0007yM-C2 for guix-patches@gnu.org; Sun, 24 Dec 2023 13:53:35 -0500 Received: from layka.disroot.org ([178.21.23.139]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rHTbR-00073N-B9 for guix-patches@gnu.org; Sun, 24 Dec 2023 13:53:35 -0500 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 92FA64190A for ; Sun, 24 Dec 2023 19:53:31 +0100 (CET) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zrfnaMrXFO9O for ; Sun, 24 Dec 2023 19:53:30 +0100 (CET) MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1703444010; bh=rVU1KERIzvkT4Z7pI2X82SlQB3UcWngelDSfsKEOKE8=; h=Date:From:To:Subject; b=bLGtO1i8mBRI9hy0dchIyEAA4XwmhyRWu5M+OEYIBJkIsh2id+fLxrXUXpq61Awt+ 1MJsSWSZ/1HvXY7pJMUwH6ZF/KjUHEYgu1VvLsURxjvsqRt8cEMi+NNcgCFqn+HWF8 IjB60sfKqSUHk2AgCxccJQyH65cb5wVeYwYngbKU9MMAnMt5EPNKUFBsSSJwkDkB5U BO9hkhZz3O9aGmO0cL4+eOtcwITKaVlrvzkBNHhbePBfyTC+W+xmHMNTLlzvJNroeJ gScmtmnovXwkYW+vwKMLx86b4mi72r95gIquuYyDIPP6RkldUQopESXyGcjqxNAs0j IjAOgEGZHQUxQ== Date: Sun, 24 Dec 2023 18:53:30 +0000 Message-ID: <29b6707c8c4cdf1808edc79813215578@disroot.org> X-Sender: lgcoelho@disroot.org Received-SPF: pass client-ip=178.21.23.139; envelope-from=lgcoelho@disroot.org; helo=layka.disroot.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Mailman-Approved-At: Sun, 24 Dec 2023 14:24:33 -0500 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: lgcoelho@disroot.org X-ACL-Warn: , lgcoelho--- via Guix-patches X-Patchwork-Original-From: lgcoelho--- via Guix-patches via From: "vasilii.smirnov--- via Guix-patches\" via" Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches This patch add thinkfan-service-type to (gnu services pm). From 92bf99099f91c0f1dae71b0cf9e5f8e6799a3679 Mon Sep 17 00:00:00 2001 From: Luis Guilherme Coelho Date: Sun, 24 Dec 2023 15:52:04 -0300 Subject: [PATCH] services: Add thinkfan service. --- gnu/services/pm.scm | 59 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/gnu/services/pm.scm b/gnu/services/pm.scm index 3daf484cc1..baded5c43e 100644 --- a/gnu/services/pm.scm +++ b/gnu/services/pm.scm @@ -31,7 +31,10 @@ (define-module (gnu services pm) tlp-configuration thermald-configuration - thermald-service-type)) + thermald-service-type + + thinkfan-configuration + thinkfan-service-type)) (define (uglify-field-name field-name) (let ((str (symbol->string field-name))) @@ -466,3 +469,57 @@ (define thermald-service-type (default-value (thermald-configuration)) (description "Run thermald, a CPU frequency scaling service that helps prevent overheating."))) + +(define-configuration/no-serialization thinkfan-configuration + (pid-file + (string "/var/run/thinkfan.pid") + "Where to store the PID file.") + (config-file + (string "/etc/thinkfan.conf") + "Configuration file to use.") + (log-file + (string "/var/log/thinkfan.log") + "File where ‘thinkfan’ writes its log to.") + (extra-options + (list-of-strings '()) + "This option provides an “escape hatch” for the user to provide +arbitrary command-line arguments to ‘thinkfan’ as a list of strings.")) + +(define thinkfan-shepherd-service + (match-record-lambda + (pid-file config-file log-file extra-options) + (list (shepherd-service + (provision '(thinkfan)) + (documentation + "Adjust fan level according to configured temperature limits.") + (requirement '(user-processes)) + (start #~(make-forkexec-constructor + (list (string-append #$thinkfan-next + "/sbin/thinkfan") + "-n" #$@extra-options + "-c" #$config-file) + #:log-file #$log-file + #:pid-file #$pid-file)) + (stop #~(make-kill-destructor)) + (one-shot? #t) + (respawn? #t))))) + +(define thinkfan-modprobe-config + (plain-file "thinkfan.conf" + "options thinkpad_acpi experimental=1 fan_control=1")) + +(define (thinkfan-modprobe-etc-service config) + `(("modprobe.d/thinkfan.conf" ,thinkfan-modprobe-config))) + +(define thinkfan-service-type + (service-type + (name 'thinkfan) + (extensions + (list (service-extension shepherd-root-service-type + thinkfan-shepherd-service) + (service-extension etc-service-type + thinkfan-modprobe-etc-service))) + (default-value (thinkfan-configuration)) + (description + "Adjust fan level according to configured temperature limits."))) + -- 2.41.0