1
0
Fork 0

feat(calendars): add calendar sync script

Signed-off-by: Lucas Sta Maria <lucas@priime.dev>
This commit is contained in:
Lucas Sta Maria 2023-12-31 00:03:12 -05:00
parent 2379ea91c6
commit ea1866cfe6
No known key found for this signature in database
GPG key ID: F07FB16A826E3B47
2 changed files with 31 additions and 0 deletions

30
.calendars/sync Normal file
View file

@ -0,0 +1,30 @@
#!/usr/bin/racket
#lang racket/base
(require racket/match)
(require racket/port)
(require net/url)
(define calendars
'())
(define (main)
(for ([calendar-info calendars])
(match-define [cons name calendar-link] calendar-info)
(define url (string->url calendar-link))
(define data (port->bytes (get-pure-port url)))
(define out-filename (format "~a.ics" name))
(when (file-exists? out-filename)
(delete-file out-filename))
(call-with-output-file out-filename
(lambda (out)
(parameterize ([current-output-port out])
(write-bytes data))))
(void)))
(module+ main
(main))

View file

@ -77,3 +77,4 @@
]; ];
.zshrc; .zshrc;
.config/kitty/kitty.conf; .config/kitty/kitty.conf;
.calendars/sync;