home-environment: radio: Setup timer-related shepherd-services

Luis Guilherme Coelho 2024-11-24 23:17:43 -03:00
parent 77d40da76f
commit 47dae46b98
No known key found for this signature in database
GPG Key ID: 1F2E76ACE3F531C8
2 changed files with 38 additions and 1 deletions

View File

@ -28,6 +28,7 @@
#|Radio|# #|Radio|#
#|C|# #:use-module ((radio channels) #:prefix channel:) #|C|# #:use-module ((radio channels) #:prefix channel:)
#|P|# #:use-module ((radio packages) #:prefix packages:) #|P|# #:use-module ((radio packages) #:prefix packages:)
#|S|# #:use-module ((radio shepherd-services) #:prefix shepherd-service:)
#|Radix|# #|Radix|#
#|C|# #:use-module (radix combinators) #|C|# #:use-module (radix combinators)
@ -145,7 +146,9 @@
#|Shepherd services|# #|Shepherd services|#
(service home-shepherd-service-type (service home-shepherd-service-type
(home-shepherd-configuration (home-shepherd-configuration
(shepherd (@ (shepherd-package) shepherd)))) (shepherd (@ (shepherd-package) shepherd))
(services (list shepherd-service:timer
shepherd-service:wake-up))))
#|Shell services|# #|Shell services|#
(service home-tty-colorscheme-service-type (service home-tty-colorscheme-service-type

View File

@ -0,0 +1,34 @@
(define-module (radio shepherd-services)
#:use-module (guix gexp)
#:use-module (gnu services shepherd)
#:use-module (shepherd service timer)
#:export (wake-up timer))
(define timer-trigger-action
(shepherd-action
(name 'trigger)
(procedure #~trigger-timer)
(documentation
"Trigger the action associated with @var{timer} as if it had reached its
next calendar event.")))
(define wake-up
(shepherd-service
(provision '(wake-up))
(modules '((shepherd service timer)))
(start #~(make-timer-constructor
(calendar-event #:hours '(6) #:minutes '(0))
(lambda ()
(use-modules (ice-9 threads))
(parallel
(system "foot -He rem")
(system "mpv --shuffle ~/media/music/by-artist")))))
(stop #~(make-timer-destructor))
(actions (list timer-trigger-action))))
(define timer
(shepherd-service
(provision '(timer))
(modules '((shepherd service timer)))
(free-form #~(timer-service))))