add hourly refresh with systemd timer
This commit is contained in:
parent
951eb71b83
commit
5f4d1f24d4
5 changed files with 48 additions and 9 deletions
29
document.typ
29
document.typ
|
|
@ -1,4 +1,7 @@
|
||||||
#set page(width: 65mm, height: 86mm)
|
#set page(width: 65mm,
|
||||||
|
height: 86mm,
|
||||||
|
margin: ("x":0cm,"y":0cm)
|
||||||
|
)
|
||||||
#let today = datetime.today()
|
#let today = datetime.today()
|
||||||
#let weather = json("weather.json")
|
#let weather = json("weather.json")
|
||||||
#let icons_map = (
|
#let icons_map = (
|
||||||
|
|
@ -32,19 +35,16 @@
|
||||||
"99": "icons/hail_day_night.svg",
|
"99": "icons/hail_day_night.svg",
|
||||||
)
|
)
|
||||||
|
|
||||||
#let decimate_array(a,n:2) = {
|
#let reduce_array(a,n:2) = {
|
||||||
let ret = ()
|
let ret = ()
|
||||||
for (i,v) in a.enumerate(){
|
for (i,v) in a.enumerate(){
|
||||||
if calc.rem-euclid(i,n) == 0{
|
if calc.rem-euclid(i,n) == 0 and i>6{
|
||||||
ret.push(v)
|
ret.push(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
#align(center)[
|
|
||||||
#text(size:1.3em, weight: "bold")[#today.display("[weekday] [month repr:long] [year]")]
|
|
||||||
|
|
||||||
#let times = ()
|
#let times = ()
|
||||||
#for i in range(24){
|
#for i in range(24){
|
||||||
times.push(datetime(hour:i,minute:0,second:0))
|
times.push(datetime(hour:i,minute:0,second:0))
|
||||||
|
|
@ -52,12 +52,23 @@
|
||||||
#let times = times.map(x=>x.display("[hour]"))
|
#let times = times.map(x=>x.display("[hour]"))
|
||||||
#let codes = weather.hourly.weather_code.map(x => image(icons_map.at(str(x)), height:1em))
|
#let codes = weather.hourly.weather_code.map(x => image(icons_map.at(str(x)), height:1em))
|
||||||
#let temps = weather.hourly.temperature_2m
|
#let temps = weather.hourly.temperature_2m
|
||||||
#let values = decimate_array(times.zip(codes,temps),n: 2)
|
#let values = reduce_array(times.zip(codes,temps),n: 2)
|
||||||
|
|
||||||
|
|
||||||
|
#align(center)[
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
|
#text(size:2em, weight: "bold")[#today.display("[weekday] [day]")]
|
||||||
|
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
#grid(
|
#grid(
|
||||||
columns: (1fr,1fr,1fr),
|
columns: (1fr,2fr,2fr),
|
||||||
..values.flatten().map(x => text(size:1.3em)[#x])
|
align: (right,center,center),
|
||||||
|
..values.flatten().map(x => text(size:1.7em)[#x])
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,11 @@ echo " - Cleanup..."
|
||||||
mv typst-aarch64-unknown-linux-musl/typst ./typst
|
mv typst-aarch64-unknown-linux-musl/typst ./typst
|
||||||
rm -rf typst-aarch64-unknown-linux-musl/
|
rm -rf typst-aarch64-unknown-linux-musl/
|
||||||
rm typst-aarch64-unknown-linux-musl.tar.xz
|
rm typst-aarch64-unknown-linux-musl.tar.xz
|
||||||
|
echo "Install systemd timer"
|
||||||
|
sudo cp moninktor-update.service /etc/systemd/system/
|
||||||
|
sudo cp moninktor-update.timer /etc/systemd/system/
|
||||||
|
chmod +x /home/grizzly/moninktor/update.sh
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable moninktor-update.timer
|
||||||
|
sudo systemctl start moninktor-update.timer
|
||||||
echo " - Done."
|
echo " - Done."
|
||||||
|
|
|
||||||
9
moninktor-update.service
Normal file
9
moninktor-update.service
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Moninktor Update Script
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
User=grizzly
|
||||||
|
ExecStart=/home/grizzly/moninktor/update.sh
|
||||||
|
WorkingDirectory=/home/grizzly/moninktor
|
||||||
10
moninktor-update.timer
Normal file
10
moninktor-update.timer
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Run Moninktor Update Script every hour
|
||||||
|
Requires=moninktor-update.service
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=hourly
|
||||||
|
Persistent=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
echo "Get weather data..."
|
echo "Get weather data..."
|
||||||
wget -O weather.json "https://api.open-meteo.com/v1/forecast?latitude=43.4516&longitude=-80.4925&hourly=temperature_2m,weather_code&start_date=2025-08-23&end_date=2025-08-23&timezone=America/Toronto"
|
wget -O weather.json "https://api.open-meteo.com/v1/forecast?latitude=43.4516&longitude=-80.4925&hourly=temperature_2m,weather_code&start_date=2025-08-23&end_date=2025-08-23&timezone=America/Toronto"
|
||||||
echo "Generate document..."
|
echo "Generate document..."
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue