2019-09-25 12:04:12 +00:00
|
|
|
{ config, lib, pkgs, buildPythonPackage, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
mq = "192.168.8.11";
|
|
|
|
pkg = pkgs.ampel;
|
|
|
|
in {
|
|
|
|
systemd.services.comic-updater = {
|
|
|
|
startAt = "daily";
|
2020-08-12 10:23:01 +00:00
|
|
|
description = "update our comics";
|
2019-09-25 12:04:12 +00:00
|
|
|
after = [ "network-online.target" ] ++ (lib.optional config.services.mosquitto.enable "mosquitto.service");
|
|
|
|
path = with pkgs; [ wget xmlstarlet ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
User = "hass";
|
|
|
|
WorkingDirectory = config.services.home-assistant.configDir;
|
2020-08-12 10:23:01 +00:00
|
|
|
ExecStart = pkgs.writeDash "update-comics" ''
|
2019-09-25 12:04:12 +00:00
|
|
|
set -euf
|
|
|
|
mkdir -p www/
|
|
|
|
cd www/
|
2020-08-12 10:23:01 +00:00
|
|
|
# poorly drawn lines
|
2019-09-25 12:04:12 +00:00
|
|
|
pic=$(wget -O- http://www.poorlydrawnlines.com/feed/ \
|
|
|
|
| xml sel -t -v '/rss/channel/item/content:encoded' \
|
|
|
|
| head -n 2 | sed -n 's/.*src="\([^"]\+\)".*/\1/p' )
|
|
|
|
wget "$pic" -nc && cp -v "$(basename "$pic")" lines.png
|
2020-08-12 10:23:01 +00:00
|
|
|
|
|
|
|
#pic=$(curl -L xkcd.com 2>/dev/null | grep imgs.xkcd.com | grep title | sed -n 's/.*src="\([^"]\+\)" .*/https:\1/p')
|
|
|
|
# xkcd
|
|
|
|
pic=$(wget -O- https://xkcd.com/rss.xml \
|
|
|
|
| xml sel -t -v '/rss/channel/item/description' \
|
|
|
|
| head -n 1 | sed -n 's/.*src="\([^"]\+\)".*/\1/p' )
|
|
|
|
wget "$pic" -nc && cp -v "$(basename "$pic")" xkcd.png
|
2019-09-25 12:04:12 +00:00
|
|
|
'';
|
|
|
|
PrivateTmp = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|