add wikipedia fact

This commit is contained in:
grizzly 2025-08-23 16:41:40 -04:00
parent 3fb3c4f63f
commit 26a2cfb91b
3 changed files with 20 additions and 34 deletions

View file

@ -6,7 +6,7 @@ from PIL import Image
epd = epd4in2.EPD()
epd.init()
image = Image.open('./document_ready.bmp')
image = Image.open('./document.bmp')
image = image.convert('L')
epd.display_4Gray(epd.getbuffer_4Gray(image))
epd.sleep()

View file

@ -1,43 +1,26 @@
#set page(width: 86mm, height: 65mm)
#let weekdays = ("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")
#set page(width: 65mm, height: 86mm)
#let today = datetime.today()
#let weather = json("weather.json")
#align(center)[
#text(size:2em)[#today.display("[weekday] [month repr:long] [year]")]
#box(
stroke: 0.2em+black
)[
#grid(
columns: (1fr,1fr,1fr,1fr,1fr,1fr,1fr),
inset:0.5em,
rows:1,
align:center,
fill: (x, _) =>
if x>4 { luma(240) }
else { white },
stroke: (x, _) =>
if x== weekdays.position(it => {it == today.display("[weekday repr:short]")}) {0.15em+black}
else { none},
[Lun],[Mar],[Mer],[Jeu],[Ven],[Sam],[Dim]
)
]
#let icon = none
#if weather.current.weather_code == 0{
icon = image("icons/sun.svg", width:3em)
}
#align(center)[
#text(size:2em, weight: "bold")[#today.display("[weekday] [month repr:long] [year]")]
#v(1fr)
#grid(
columns: (1fr,4fr),
columns: (1fr,2fr),
align: (center+horizon, left+horizon),
[#icon],[#text(size:3em)[#weather.current.temperature_2m #weather.current_units.temperature_2m]]
)
#v(1fr)
#read("event.txt")
#v(1fr)
]

View file

@ -1,7 +1,10 @@
echo "Get Wikipedia fact..."
wget -qO- "https://api.wikimedia.org/feed/v1/wikipedia/en/onthisday/events/$(date +%m)/$(date +%d)" | \
jq -r '.events[0] | "\(.year): \(.text)"' > event.txt
echo "Generate document..."
./typst compile --format png document.typ
echo "Convert to image..."
mogrify -resize 400x300^ -gravity center -extent 400x300 document_ready.png document_ready.bmp
convert -rotate 90 -resize 400x300^ -gravity center -extent 400x300 document.png document.bmp
echo "Update display..."
python3 display.py
echo "Done."