summaryrefslogtreecommitdiffstats
path: root/mowedline/.config/mowedline/init.scm
blob: fac1fd26526a1af7f2a84b4d0d9aed6dc91c8e10 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
(use srfi-1 matchable)

(define (not-text? text)
  (or (null? text) (and (not (pair? text)) (string-null? text))))

(define (text-maybe-pad-both text)
  (if (not-text? text)
      text
      (L " " text " ")))

(define (text-maybe-pad-right text)
  (if (not-text? text)
      text
      (L text " ")))

(define (add-fa-icon icon)
  (lambda (text)
    (if (not-text? text)
        text
        (list (list 'font "FontAwesome-10"
                    (string-append " " icon " "))
              text))))

(define (split-tag-list str)
  (map string->list (string-split str "\t")))

(define tag-display
  (match-lambda
    ((#\# n) (L (L 'color "#ececec" 'font "FontAwesome-10" "") " "))
    ((#\- n) (L (L 'color "#bfbfbf" 'font "FontAwesome-10" "") " "))
    ((#\. n) (L (L 'color "#969696" 'font "FontAwesome-10" "") " "))
    ((#\: n) (L (L 'color "#969696" 'font "FontAwesome-10" "") " "))
    ((#\! n) (L (L 'color "#a85454" 'font "FontAwesome-10" "") " "))))

(define (tag-list-display tag-list)
  (map tag-display tag-list))

(define (tag-list-formatter text)
  (let ((tag-list (split-tag-list text)))
    (tag-list-display tag-list)))

(text-widget-font "Fantasque Sans Mono-13:bold")
(text-widget-color "#ededed")
(text-widget-format text-maybe-pad-both)

(define tag-list-widget
  (widget:text 'name "taglist" 'format tag-list-formatter))

(define window-title-widget
  (widget:active-window-title 'format text-maybe-pad-right))

(define mpd-widget
  (widget:text 'name "mpd" 'format (add-fa-icon "")))

(define irc-list-widget
  (widget:text 'name "irclist" 'format identity))

(define email-widget
  (widget:text 'name "email"
               'format (compose text-maybe-pad-both (add-fa-icon ""))))

(define cam-status-widget
  (widget:flags 'name "cam-status"
                'font "FontAwesome-10"
                'flags '(("suspended" color "#a88654" "")
                         ("active" color "#65a854" "")
                         ("unplugged" color "#a85454" ""))))

(define key-chain-widget
  (widget:flags 'name "keychain"
                'font "FontAwesome-10"
                'flags '(("Unlocked" color "#65a854" "")
                         ("Locked" color "#a85454" ""))))

(define clock-widget
  (widget:clock 'format text-maybe-pad-left))

(window 'position 'bottom
        'width 1843
        'margin-bottom 15
        'margin-left 46
        'margin-right 15
        'background 'transparent

        tag-list-widget
        window-title-widget
        (widget:spacer 'flex 1)
        mpd-widget
        irc-list-widget
        email-widget
        cam-status-widget
        key-chain-widget
        clock-widget)