diff --git a/document.typ b/document.typ index ea27728..e7ffc51 100644 --- a/document.typ +++ b/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 weather = json("weather.json") #let icons_map = ( @@ -32,19 +35,16 @@ "99": "icons/hail_day_night.svg", ) -#let decimate_array(a,n:2) = { +#let reduce_array(a,n:2) = { let ret = () 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) } } return ret } -#align(center)[ - #text(size:1.3em, weight: "bold")[#today.display("[weekday] [month repr:long] [year]")] - #let times = () #for i in range(24){ times.push(datetime(hour:i,minute:0,second:0)) @@ -52,12 +52,23 @@ #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 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( - columns: (1fr,1fr,1fr), - ..values.flatten().map(x => text(size:1.3em)[#x]) + columns: (1fr,2fr,2fr), + align: (right,center,center), + ..values.flatten().map(x => text(size:1.7em)[#x]) ) + +#v(1fr) ] diff --git a/install.sh b/install.sh index db5e94a..6afc385 100755 --- a/install.sh +++ b/install.sh @@ -8,4 +8,11 @@ echo " - Cleanup..." mv typst-aarch64-unknown-linux-musl/typst ./typst rm -rf typst-aarch64-unknown-linux-musl/ 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." diff --git a/moninktor-update.service b/moninktor-update.service new file mode 100644 index 0000000..5be72de --- /dev/null +++ b/moninktor-update.service @@ -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 diff --git a/moninktor-update.timer b/moninktor-update.timer new file mode 100644 index 0000000..4fe5fc4 --- /dev/null +++ b/moninktor-update.timer @@ -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 diff --git a/update.sh b/update.sh index 912e382..78cc8c6 100755 --- a/update.sh +++ b/update.sh @@ -1,3 +1,5 @@ +#!/bin/bash + 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" echo "Generate document..."