summaryrefslogtreecommitdiffstats
path: root/lass/2configs/radio-news.nix
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2022-02-07 17:32:13 +0100
committerlassulus <lassulus@lassul.us>2022-02-07 17:32:13 +0100
commitb0d602cc15f2bc361bb88d062d37e50190e244de (patch)
tree8da5e055765ca6bf9ae10ee70ddd874213b8dc19 /lass/2configs/radio-news.nix
parenta2c6601f4bcd54ab099b43b97f84dcda3bf43d92 (diff)
l: add hourly newsshow to radio
Diffstat (limited to 'lass/2configs/radio-news.nix')
-rw-r--r--lass/2configs/radio-news.nix51
1 files changed, 51 insertions, 0 deletions
diff --git a/lass/2configs/radio-news.nix b/lass/2configs/radio-news.nix
new file mode 100644
index 000000000..8e48009a8
--- /dev/null
+++ b/lass/2configs/radio-news.nix
@@ -0,0 +1,51 @@
+{ config, pkgs, ... }: with pkgs.stockholm.lib;
+let
+ weather_report = pkgs.writers.writeDashBin "weather_report" ''
+ set -efu
+ ${pkgs.curl}/bin/curl -sSL https://wttr.in/''${1-}?format=j1 \
+ | ${pkgs.jq}/bin/jq -r '
+ [.nearest_area[0] | "Weather report for \(.areaName[0].value), \(.country[0].value)."]
+ + [.current_condition[0] | "Currently it is \(.weatherDesc[0].value) outside with a temperature of \(.temp_C) degrees."]
+ | join("\n")
+ '
+ '';
+ send_to_radio = pkgs.writers.writeDashBin "send_to_radio" ''
+ ${pkgs.vorbisTools}/bin/oggenc - |
+ ${pkgs.libshout}/bin/shout --format ogg --host localhost --port 1338 --mount /live
+ '';
+
+ newsshow = pkgs.writers.writeDashBin "newsshow" /* sh */ ''
+ echo "
+ hello crabpeople!
+ $(${pkgs.ddate}/bin/ddate | sed 's/YOLD/Year of Discord/')!
+ It is $(date --utc +%H) o clock UTC.
+ $(weather_report berlin)
+ $(weather_report stuttgart)
+ $(weather_report munich)
+ "
+ '';
+in
+{
+ systemd.services.newsshow = {
+ path = [
+ newsshow
+ send_to_radio
+ weather_report
+ pkgs.curl
+ ];
+ script = ''
+ set -efu
+ newsshow |
+ curl -SsG http://tts.r/api/tts --data-urlencode 'text@-' |
+ send_to_radio
+ '';
+ startAt = "*:00:00";
+ };
+
+ ## debug
+ # environment.systemPackages = [
+ # weather_report
+ # send_to_radio
+ # newsshow
+ # ];
+}