summaryrefslogtreecommitdiff
path: root/.config/nyxt/statusline.lisp
blob: a90527e96b55fab38f32cf8c96cbbc31d8f9b038 (about) (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
;; (in-package #:nyxt-user)

;; ;; Set StatusLines Mode Icons
;; (define-configuration status-buffer ((glyph-mode-presentation-p t)))
;; (define-configuration nyxt/force-https-mode:force-https-mode ((glyph "")))
;; (define-configuration nyxt/blocker-mode:blocker-mode ((glyph "")))
;; (define-configuration nyxt/proxy-mode:proxy-mode ((glyph "")))
;; (define-configuration nyxt/reduce-tracking-mode:reduce-tracking-mode  ((glyph "")))
;; (define-configuration nyxt/certificate-exception-mode:certificate-exception-mode ((glyph "")))
;; (define-configuration nyxt/style-mode:style-mode ((glyph "")))
;; (define-configuration nyxt/help-mode:help-mode ((glyph "")))
;; (define-configuration nyxt/web-mode:web-mode ((glyph "ω")))
;; (define-configuration nyxt/auto-mode:auto-mode ((glyph "α")))

;;Set StatusLines URL Icons
(defun laconic-format-status-load-status (buffer)
 (if (web-buffer-p buffer)
     (case (slot-value buffer 'nyxt::load-status)
       (:unloaded "∅")
       (:loading "∞")
       (:finished ""))
     ""))

;;Remove https/www from URL
(defun laconic-format-status-url (buffer)
 (markup:markup
  (:span
      (format nil "~a ~a"
              (laconic-format-status-load-status buffer)
              (ppcre:regex-replace-all
               "(https://|www\\.|/$)"
               (render-url (url buffer))
               "")))))

;;Set StatusLines Webpage Loadtime
(defun laconic-format-status-modes (buffer window)
 (str:concat
  (format-status-modes buffer window)
  " | "
  (format nil "~d:~d"
          (mod (+ 5 (local-time:timestamp-hour (local-time:now))) 24)
          (local-time:timestamp-minute (local-time:now)))))

;;Configure StatusLines Design
(defun laconic-format-status (window)
 (flet ((input-indicating-background ()
          (format nil "background-color: ~:[#50fa7b~;#ff5555~]"
                  (or (current-mode 'vi-insert)
                      (current-mode 'input-edit)))))
   (let ((buffer (current-buffer window)))
     (markup:markup
      (:div :id "container"
            (:div :id "controls"
                  :style (input-indicating-background)
                  (markup:raw ""))
            (:div :class "arrow arrow-right"
                  :style (input-indicating-background) "")
            (:div :id "url"
                  (markup:raw
                   (laconic-format-status-url buffer)))
            (:div :class "arrow arrow-right"
                  :style "background-color:#21222C" "")
            (:div :id "tabs"
                  (title buffer))
            (:div :class "arrow arrow-left"
                  :style "background-color:#21222C" "")
            (:div :id "modes"
                  :title (nyxt::list-modes buffer)
                  (laconic-format-status-modes buffer window)))))))

;;Define Current Configuration
(define-configuration window
 ((status-formatter #'laconic-format-status)))