-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexwm-telephone-line-mode-line.el
299 lines (230 loc) · 9.15 KB
/
exwm-telephone-line-mode-line.el
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
(use-package telephone-line)
(use-package unicode-fonts
:config
(unicode-fonts-setup))
(setq telephone-line-primary-left-separator 'telephone-line-utf-abs-left
telephone-line-secondary-left-separator 'telephone-line-utf-abs-hollow-left
telephone-line-primary-right-separator 'telephone-line-utf-abs-right
telephone-line-secondary-right-separator 'telephone-line-utf-abs-hollow-right
)
(defvar my-font-height-modifier 10
"Default value to increment the size by when jacking into a monitor.")
(defun my-increase-modeline-font ()
(interactive)
(set-face-attribute 'mode-line nil :height (+ (face-attribute 'mode-line :height)
my-font-height-modifier)))
(defun my-decrease-modeline-font ()
(interactive)
(set-face-attribute 'mode-line nil :height (- (face-attribute 'mode-line :height)
my-font-height-modifier)))
;; specify font for all unicode characters
(when (member "DejaVu Sans Mono for Powerline" (font-family-list))
(set-fontset-font t 'unicode "DejaVu Sans Mono for Powerline" nil 'prepend))
;; Format for time string
(setq display-time-string-forms
'((propertize (concat "TIME: " 24-hours ":" minutes " " am-pm))))
(set-face-attribute 'mode-line nil
:foreground "Orange" ;;Yellow"
:background "Blue2"
:inverse-video nil
:weight 'bold
:height (* (window-font-height) 6)
:box '(:line-width 6 :color "orange" :style nil)
)
(set-face-attribute 'mode-line-inactive nil
;;:foreground "Orange"
:background "gray22"
:inverse-video nil
:weight 'bold
:height (* (window-font-height) 6)
:box '(:line-width 6 :color "white" :style nil)
)
(set-face-attribute 'telephone-line-accent-active nil
:foreground "Black" ;;Yellow"
:background "Orange"
:inverse-video nil
:weight 'bold
:height (* (window-font-height) 6)
:box '(:line-width 6 :color "orange" :style nil))
(set-face-attribute 'telephone-line-accent-inactive nil
:foreground "White"
:background "Black"
:inverse-video nil
:weight 'bold
:height (* (window-font-height) 6)
;;:box '(:line-width 6 :color "orange" :style nil)
:box '(:line-width 6 :color "white" :style nil)
)
(set-face-attribute 'telephone-line-evil nil
:foreground "Orange" ;;Yellow"
:background "Blue2"
:inverse-video nil
:weight 'bold
:height (* (window-font-height) 6)
:box '(:line-width 6 :color "orange" :style nil))
(set-face-attribute 'telephone-line-evil-visual nil :background "light sea green")
(make-face 'mode-line-mode-face)
(make-face 'mode-line-folder-face)
(make-face 'mode-line-filename-face)
(make-face 'mode-line-index-face)
(set-face-attribute 'mode-line-mode-face nil
:inherit 'mode-line
:foreground "gray80")
(set-face-attribute 'mode-line-folder-face nil
:inherit 'mode-line
:foreground "white" ;"gray22"
:weight 'bold)
(set-face-attribute 'mode-line-filename-face nil
:inherit 'mode-line
:foreground "#eab700"
:weight 'ultra-bold)
;; Helper function
(defun shorten-directory (dir max-length)
"Show up to `max-length' characters of a directory name `dir'."
(let ((path (reverse (split-string (abbreviate-file-name dir) "/")))
(output ""))
(when (and path (equal "" (car path)))
(setq path (cdr path)))
(while (and path (< (length output) (- max-length 4)))
(setq output (concat (car path) "/" output))
(setq path (cdr path)))
(when path
(setq output (concat ".../" output)))
output))
(setq spaceline-window-numbers-unicode t)
;; from https://github.com/TheBB/spaceline/blob/master/spaceline-segments.el
(defun spaceline--unicode-number (str)
"Return a nice unicode representation of a single-digit number STR."
(cond
((string= "1" str) "➊")
((string= "2" str) "➋")
((string= "3" str) "➌")
((string= "4" str) "➍")
((string= "5" str) "➎")
((string= "6" str) "➏")
((string= "7" str) "➐")
((string= "8" str) "➑")
((string= "9" str) "➒")
((string= "10" str) "➓")
(t str)))
(defun get-window-number ()
"The current window number.
Requires either `winum-mode' or `window-numbering-mode' to be enabled."
(let* ((num (cond
((bound-and-true-p winum-mode)
(winum-get-number))
((bound-and-true-p window-numbering-mode)
(window-numbering-get-number))
(t nil)))
(str (when num (int-to-string num))))
(when num
(if spaceline-window-numbers-unicode
(spaceline--unicode-number str)
(propertize str 'face 'bold)))))
(defun get-exwm-workspace-number ()
(let* ((num (cond
((bound-and-true-p exwm-workspace-current-index)
exwm-workspace-current-index)
(t nil)))
(str (when num (int-to-string num))))
(when num
(if spaceline-window-numbers-unicode
(spaceline--unicode-number str)
(propertize str 'face 'bold)))))
;; (defface my-winnum-face
;; '((t ((:inherit mode-line :height (* (window-font-height) 20)))))
;; "Face for the window number in the mode line"
;; :group 'telephone-line
;; )
;; (set-face-attribute 'my-winnum-face nil
;; :height 1000);; (* (window-font-height) 60))
(set-face-attribute 'winum-face nil :height (* 6 (window-font-height)) :weight 'extra-bold)
(telephone-line-defsegment my-telephone-line-window-number-segment (&optional in-unicode)
(when (bound-and-true-p winum-mode)
(propertize (get-window-number) 'face 'winum-face)))
(defun jw/input-mode-str ()
"Return string representing input mode, if window is of type EXWM"
(if exwm-window-type
(if (eq exwm--input-mode 'line-mode)
(format " Ⓛ ")
(format " Ⓒ "))
(format "")))
;; Display the current EXWM workspace index in the mode-line
(telephone-line-defsegment telephone-line-exwm-workspace-index ()
(when (bound-and-true-p exwm-workspace-current-index)
(propertize (format "wksp:%s %s" (get-exwm-workspace-number) (jw/input-mode-str)) 'face 'winum-face))
;;(format "Wksp:%s" (get-exwm-workspace-number)))
)
(telephone-line-defsegment* my-telephone-line-buffer-segment ()
`(" "
;;mode-line-mule-info
;;mode-line-modified
;;mode-line-client
;;mode-line-remote
mode-line-frame-identification
,(if buffer-file-name (telephone-line-raw (shorten-directory default-directory 30) t))
,(telephone-line-raw "%b" t)
" "
;;,(telephone-line-raw mode-line-buffer-identification t)
))
;;(setq telephone-line-height 20) ;; 30
(setq telephone-line-lhs
'((evil . (telephone-line-evil-tag-segment))
(nil . (my-telephone-line-window-number-segment))
(accent . nil)
(nil . (telephone-line-exwm-workspace-index))
(accent . (telephone-line-input-info-segment))
(nil . (my-telephone-line-buffer-segment))
(accent . (;;telephone-line-vc-segment
;;telephone-line-erc-modified-channels-segment
;;telephone-line-process-segment
;;telephone-line-misc-info-segment
))
(nil . nil)
(nil . (telephone-line-major-mode-segment
;;telephone-line-buffer-segment
))
(nil . nil)
(accent . nil)
(nil . nil)
(accent . nil)
(nil . nil)
(accent . nil)
))
(setq telephone-line-center-lhs
'(
(accent . (telephone-line-misc-info-segment))
(nil . nil)
(accent . nil)
(nil . nil)
(accent . nil)
;(nil . nil)
(nil . (telephone-line-vc-segment))
(accent . nil)
(nil . nil)
(accent . nil)
(nil . nil)
(accent . (telephone-line-airline-position-segment))
(nil . nil)
(accent . nil)
(nil . nil)
(accent . nil)
(nil . nil)
;;(accent . nil)
;;(nil . nil)
))
(setq telephone-line-rhs
'(
;;(nil . nil)
;;(accent . nil)
;;(nil . nil)
;;(accent . nil );;(telephone-line-misc-info-segment))
;;(nil . nil) ;(telephone-line-airline-position-segment))
(nil . (telephone-line-minor-mode-segment))
(evil . (telephone-line-evil-tag-segment))
))
(telephone-line-mode 1)
(setq mode-line-format
(if telephone-line-mode
`("%e" ,@(telephone-line--generate-mode-line))
telephone-line--default-mode-line))