aboutsummaryrefslogtreecommitdiff
path: root/module/config.scm
blob: d62b05db51593aa1cbc653a0cf585c11fb9a59cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
;;; Preliminary config file for the system.
;;; Currently loaded by main, and requires that `calendar-files`
;;; is set to a list of files (or directories).

(define-module (config) #:use-module (parameters))

(use-modules (srfi srfi-26)
             (srfi srfi-88)
             (ice-9 ftw)
             (ice-9 regex)
             (ice-9 rdelim))

(define (p str)
  "Pathify string."
  (regexp-substitute/global
   #f "~[^/]*" str
   'pre (lambda (_) (getenv "HOME")) 'post))

(define (filename-hidden? str)
  (char=? #\. (string-ref str 0)))

(calendar-files
 (let ((path #; "/mnt/arch/home/hugo/.calendars/"
        (p "~/.calendars/")))
   (map (cut string-append path <>)
        (scandir path (negate filename-hidden?)))))

;;; TODO possibly replace with propper lookup
(define my-courses
  '((TSEA82 . "Datorteknik")
    (TFYA19 . "Kvantdatorer")
    (TATA42 . "Tvåvarren")
    (TSRT04 . "Matlab")
    (TDDC78 . "Paralellprogrammering")
    (TDDB68 . "Pintos")))

(define* (aref alist key optional: default)
  (or (assoc-ref alist key) default key))

(summary-filter
 (lambda (ev str)
   (regexp-substitute/global
    #f "T[A-Z]{3}[0-9]{2}" str
    'pre (lambda (m) (aref my-courses (string->symbol (match:substring m))))
    'post)))