From 47dae46b98ad1e8af4b0b1f52b98696b13e84472 Mon Sep 17 00:00:00 2001 From: Luis Guilherme Coelho Date: Sun, 24 Nov 2024 23:17:43 -0300 Subject: [PATCH] home-environment: radio: Setup timer-related shepherd-services --- home-environments/radio.scm | 5 ++- home-environments/radio/shepherd-services.scm | 34 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 home-environments/radio/shepherd-services.scm diff --git a/home-environments/radio.scm b/home-environments/radio.scm index 69180ba..b092c3e 100644 --- a/home-environments/radio.scm +++ b/home-environments/radio.scm @@ -28,6 +28,7 @@ #|Radio|# #|C|# #:use-module ((radio channels) #:prefix channel:) #|P|# #:use-module ((radio packages) #:prefix packages:) + #|S|# #:use-module ((radio shepherd-services) #:prefix shepherd-service:) #|Radix|# #|C|# #:use-module (radix combinators) @@ -145,7 +146,9 @@ #|Shepherd services|# (service home-shepherd-service-type (home-shepherd-configuration - (shepherd (@ (shepherd-package) shepherd)))) + (shepherd (@ (shepherd-package) shepherd)) + (services (list shepherd-service:timer + shepherd-service:wake-up)))) #|Shell services|# (service home-tty-colorscheme-service-type diff --git a/home-environments/radio/shepherd-services.scm b/home-environments/radio/shepherd-services.scm new file mode 100644 index 0000000..733763d --- /dev/null +++ b/home-environments/radio/shepherd-services.scm @@ -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))))