Skip to content

Commit c933bac

Browse files
committed
Add configurable workspace numbering (#2)
1 parent f72e658 commit c933bac

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

exwm-modeline.el

+25-3
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,20 @@ switch, so the number of updates is increased significantly."
9696
(advice-remove #'exwm--update-hints #'exwm-modeline--urgency-advice)
9797
(remove-hook 'exwm-workspace-switch-hook #'exwm-modeline--urgency-advice)))))
9898

99+
(defcustom exwm-modeline-workspace-index-map 'exwm-workspace-index-map
100+
"Function for mapping a workspace index to a string for display.
101+
102+
If the value if 'exwm-workspace-index-map, dereference the
103+
`exwm-workspace-index-map'variable. Otherwise, use a function."
104+
:group 'exwm-workspace
105+
:type '(choice
106+
(symbol exwm-workspace-index-map :tag "Use EXWM default")
107+
(function))
108+
:set (lambda (sym value)
109+
(set-default sym value)
110+
(when (bound-and-true-p exwm-modeline-mode)
111+
(exwm-modeline-update))))
112+
99113
(defface exwm-modeline-current-workspace
100114
;; I'd rather :inherit and override warning there, but well
101115
`((t :foreground ,(face-foreground 'warning) :weight bold))
@@ -130,14 +144,22 @@ Always return nil if `exwm-modeline-display-urgent' is not set."
130144
if (eq frame (buffer-local-value 'exwm--frame (cdr item)))
131145
return t))
132146

147+
(defun exwm-modeline--workspace-index-map (i)
148+
"Map the workspace index I to a string for display.
149+
150+
See `exwm-modeline-workspace-index-map' for behaviour."
151+
(if (eq exwm-modeline-workspace-index-map 'exwm-workspace-index-map)
152+
(funcall exwm-workspace-index-map i)
153+
(funcall exwm-modeline-workspace-index-map i)))
154+
133155
(defun exwm-modeline--click (event)
134156
"Process a click EVENT on the modeline segment."
135157
(interactive "e")
136158
(when-let
137159
(target
138160
(cl-loop with name = (format "%s" (car (posn-string (event-start event))))
139161
for i from 0 to (1- (length exwm-workspace--list))
140-
if (string-equal (funcall exwm-workspace-index-map i) name)
162+
if (string-equal (exwm-modeline--workspace-index-map i) name)
141163
return i))
142164
(exwm-workspace-switch target)))
143165

@@ -153,8 +175,8 @@ Always return nil if `exwm-modeline-display-urgent' is not set."
153175
WORKSPACE-LIST is the list of frames to display."
154176
(cl-loop for frame in workspace-list
155177
for i from 0 to (length workspace-list)
156-
for workspace-name = (funcall exwm-workspace-index-map
157-
(exwm-workspace--position frame))
178+
for workspace-name = (exwm-modeline--workspace-index-map
179+
(exwm-workspace--position frame))
158180
with current-frame = (selected-frame)
159181
if (= i 0) collect (nth 0 exwm-modeline-dividers)
160182
collect

0 commit comments

Comments
 (0)