56 lines
2.3 KiB
Scheme
56 lines
2.3 KiB
Scheme
|
(define-module (radix services linux)
|
||
|
#:use-module (gnu)
|
||
|
#:use-module (radix packages linux)
|
||
|
#:use-module (gnu services)
|
||
|
#:use-module (gnu services shepherd)
|
||
|
#:use-module (guix gexp)
|
||
|
#:use-module (guix records)
|
||
|
#:export (<thinkfan-configuration>
|
||
|
thinkfan-configuration
|
||
|
make-thinkfan-configuration
|
||
|
thinkfan-configuration?
|
||
|
thinkfan-shepherd-service
|
||
|
thinkfan-service-type))
|
||
|
|
||
|
(define-record-type* <thinkfan-configuration>
|
||
|
thinkfan-configuration make-thinkfan-configuration
|
||
|
thinkfan-configuration?
|
||
|
(requirement thinkfan-configuration-requirement ;list of symbols
|
||
|
(default '(user-processes)))
|
||
|
(pid-file thinkfan-configuration-pid-file ;string
|
||
|
(default "/var/run/thinkfan.pid"))
|
||
|
(config-file thinkfan-configuration-config-file ;#f | file-like
|
||
|
(default #f))
|
||
|
(respawn? thinkfan-configuration-respawn? ;boolean
|
||
|
(default #t))
|
||
|
(extra-options thinkfan-configuration-extra-options ;list of strings
|
||
|
(default '())))
|
||
|
|
||
|
(define (thinkfan-shepherd-service config)
|
||
|
(match-record config <thinkfan-configuration>
|
||
|
(requirement pid-file config-file respawn? extra-options)
|
||
|
(list (shepherd-service
|
||
|
(provision '(thinkfan))
|
||
|
(documentation
|
||
|
"Adjust fan level according to configured temperature limits.")
|
||
|
(requirement requirement)
|
||
|
(start #~(make-forkexec-constructor
|
||
|
(list (string-append #$thinkfan-next "/sbin/thinkfan")
|
||
|
#$@(if config-file
|
||
|
#~((string-append "-c" #$config-file))
|
||
|
#~())
|
||
|
#$@extra-options)
|
||
|
#:pid-file #$pid-file))
|
||
|
(stop #~(make-kill-destructor))
|
||
|
(one-shot? #t)
|
||
|
(respawn? respawn?)))))
|
||
|
|
||
|
(define thinkfan-service-type
|
||
|
(service-type (name 'thinkfan)
|
||
|
(extensions
|
||
|
(list (service-extension shepherd-root-service-type
|
||
|
thinkfan-shepherd-service)))
|
||
|
(default-value (thinkfan-configuration))
|
||
|
(description
|
||
|
"Adjust fan level according to configured temperature limits.")))
|