From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: Re: Of sounds and locales Date: Sun, 25 Oct 2015 22:07:36 +0300 Message-ID: <871tcig41z.fsf@gmail.com> References: <725fd1253bc420d3e1e6bfa49bbf9b79@autoproduzioni.net> <87twsp47bm.fsf@netris.org> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZqQdq-0001VN-BE for guix-devel@gnu.org; Sun, 25 Oct 2015 15:07:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZqQdn-0002Ei-5Z for guix-devel@gnu.org; Sun, 25 Oct 2015 15:07:42 -0400 Received: from mail-lf0-x229.google.com ([2a00:1450:4010:c07::229]:33652) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZqQdm-0002Ec-Qa for guix-devel@gnu.org; Sun, 25 Oct 2015 15:07:39 -0400 Received: by lffv3 with SMTP id v3so127017929lff.0 for ; Sun, 25 Oct 2015 12:07:38 -0700 (PDT) In-Reply-To: (matias jose seco's message of "Sat, 24 Oct 2015 15:28:52 +0000") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: matias_jose_seco@autoproduzioni.net Cc: guix-devel@gnu.org matias_jose_seco@autoproduzioni.net (2015-10-24 18:28 +0300) wrote: > As always destiny seems to challenge our will to reach the peak! > >> Another option to reduce the whistle is to run "powertop --auto-tune" >> after boot. Here's a service definition I put into my OS config to >> do this: >> >> --8<---------------cut here---------------start------------->8--- >> (define (powertop-auto-tune-service) >> (let ((powertop #~(string-append #$powertop "/sbin/powertop"))) >> (with-monad %store-monad >> (return >> (service >> (documentation "Run powertop --auto-tune.") >> (provision '(powertop-auto-tune)) >> (requirement '(user-processes)) >> (start #~(lambda _ >> (zero? (system* #$powertop "--auto-tune"))))))))) >> --8<---------------cut here---------------end--------------->8--- >> >> And then include (powertop-auto-tune-service) in the 'services' field. >> Note, you'll need to import some extra modules at the top of the file: >> >> --8<---------------cut here---------------start------------->8--- >> (use-modules (gnu) >> (gnu services) >> (guix gexp) >> (guix store) >> (guix monads)) >> --8<---------------cut here---------------end--------------->8--- >> >> [...] >> >> My workaround was to add another service that disables the >> second CPU core when it gets too hot. Here's the service definition I >> used: >> >> --8<---------------cut here---------------start------------->8--- >> (define (temperature-regulation-service) >> (with-monad %store-monad >> (return >> (service >> (documentation "Regulate temperature on an overclocked Libreboot >> X60.") >> (provision '(temperature-regulation)) >> (requirement '(user-processes)) >> (start #~(lambda _ >> (let ((pid (primitive-fork))) >> (if (positive? pid) >> pid >> (let () >> (define (current-temp) >> (call-with-input-file >> "/sys/class/thermal/thermal_zone0/temp" >> read)) >> (define (set-cpu1-online! online?) >> (call-with-output-file >> "/sys/devices/system/cpu/cpu1/online" >> (lambda (port) >> (write (if online? 1 0) port)))) >> (let loop () >> (let ((temp (current-temp))) >> (cond ((< temp 88000) (set-cpu1-online! >> #t)) >> ((> temp 92000) (set-cpu1-online! >> #f)))) >> (sleep 2) >> (loop))))))) >> (stop #~(make-kill-destructor)) >> (respawn? #t))))) >> --8<---------------cut here---------------end--------------->8--- >> >> and as above, you'll need to add (temperature-regulation-service) to >> the >> services field, and of course run "guix system reconfigure " >> and reboot. >> > > Should i add (define (temperature-regulation-service)... > and (define (powertop-auto-tune-service)... > inside (operating-system) definition ? Nope, these are top-level definition, so it should be done like this: (define ...) (operating-system ...) By the way, recently the service API was changed, so those service definitions will not work anymore. -- Alex