-
Notifications
You must be signed in to change notification settings - Fork 5
/
mode-line.lisp
89 lines (73 loc) · 2.83 KB
/
mode-line.lisp
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
(in-package :cl-user)
(defpackage hfj.mode-line
(:use :cl :hfj :stumpwm))
(in-package :hfj.mode-line)
(ql:quickload "clx-truetype")
(setf *mode-line-position* :bottom)
;; (load-module "app-menu")
(load-module "battery-portable")
(load-module "cpu")
(load-module "mem")
(load-module "net")
(load-module "wifi")
(load-module "stumptray")
(load-module "ttf-fonts")
(xft:cache-fonts)
(set-font (make-instance 'xft:font :family "Iosevka Light" :subfamily "Regular" :size 10))
(defun only-float-windows (windows)
"Mirror of only-tile-windows."
(remove-if-not (lambda (w)
(typep w 'stumpwm::float-window))
windows))
(defun group-float-windows (group)
"Mirror of group-tile-windows."
(only-float-windows (stumpwm::group-windows group)))
(defun mode-line-hidden-windows (ml)
(let* ((group (stumpwm::mode-line-current-group ml))
(current-frame (stumpwm::tile-group-current-frame group))
(all (concatenate 'list
(group-float-windows group)
(stumpwm::frame-windows group current-frame))))
(format nil "~{~a~^ | ~}"
(mapcar (lambda (w)
(let ((str (stumpwm::format-expand *window-formatters*
*window-format*
w)))
(cond ((eq w (stumpwm::current-window))
(stumpwm::fmt-highlight str))
(t str))))
(stumpwm::sort1 all #'< :key #'window-number)))))
(add-screen-mode-line-formatter #\V #'mode-line-hidden-windows)
(setf *window-format* "%m%s%n.%8c - %20t")
(setf *group-format* "%s%t")
(defun has-battery-p ()
(or (probe-file "/sys/class/power_supply/BAT0")
(probe-file "/sys/class/power_supply/BAT1")))
(defun has-wireless-p ()
(loop
for path in (directory #P"/sys/class/net/*")
thereis (probe-file (merge-pathnames (make-pathname :directory '(:relative "wireless"))
path))))
(let ((battery (and (has-battery-p) "BAT: %B"))
(groups "%g")
(current-group "%n")
(sep " | ")
(align-right "^>")
(hidden-windows "%V")
(cpu "%c")
(cpu-bar "%C")
(cpu-temp "%t")
(cpu-freq "%f")
(mem "%M")
(wifi (and (has-wireless-p) "%I"))
(date "%d")
(_ " ")
(right-padding (make-string 7 :initial-element #\Space)))
(let ((left (list current-group sep hidden-windows))
(right (list battery (and battery _) cpu mem wifi _ date right-padding)))
(setf *screen-mode-line-format*
(list left align-right sep right))))
(setf *mode-line-timeout* 1)
(unless (stumpwm::head-mode-line (current-head))
(toggle-mode-line (current-screen) (current-head))
(run-commands "stumptray"))