1 ;;; --------------------------------------------------------------------------
2 ;;; CLFSWM - FullScreen Window Manager
4 ;;; --------------------------------------------------------------------------
5 ;;; Documentation: Toolbar
6 ;;; --------------------------------------------------------------------------
8 ;;; (C) 2012 Philippe Brochard <pbrochard@common-lisp.net>
10 ;;; This program is free software; you can redistribute it and/or modify
11 ;;; it under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or
13 ;;; (at your option) any later version.
15 ;;; This program is distributed in the hope that it will be useful,
16 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with this program; if not, write to the Free Software
22 ;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 ;;; Documentation: If you want to use this file, just add this line in
25 ;;; your configuration file:
27 ;;; (load-contrib "toolbar.lisp")
29 ;;; You can add a toolbar with the function add-toolbar in your configuration
30 ;;; file. You can obtain modules list with the list-toolbar-modules function.
32 ;;; For convenience, here is the add-toolbar documentation:
34 ;;; add-toolbar (root-x root-y direction size placement modules
35 ;;; &key (autohide *toolbar-default-autohide*)
36 ;;; (thickness *toolbar-default-thickness*)
37 ;;; (refresh-delay *toolbar-default-refresh-delay*)
38 ;;; (border-size *toolbar-default-border-size*))
39 ;;; "Add a new toolbar.
40 ;;; root-x, root-y: root coordinates or if root-y is nil, root-x is the nth root in root-list.
41 ;;; direction: one of :horiz or :vert
42 ;;; placement: same argument as with-placement macro
43 ;;; modules: list of modules: a list of module name, position in percent and arguments.
44 ;;; 0%=left/up <-> 100%=right/down.
45 ;;; Example: '((clock 1) (label 50 \"My label\") (clickable-clock 90))
46 ;;; size: toolbar size in percent of root size
47 ;;; thickness: toolbar height for horizontal toolbar or width for vertical one
48 ;;; autohide: one of nil, :click, or :motion
49 ;;; refresh-delay: refresh delay for toolbar in seconds
50 ;;; border-size: toolbar window border size"
52 ;;; Here are some examples:
53 ;;; (load-contrib "toolbar.lisp")
55 ;;; ;; Add an horizontal toolbar on root at coordinates 0,0 pixels
56 ;;; ;; with default modules
58 ;;; (add-toolbar 0 0 :horiz 80 'top-middle-root-placement *default-toolbar*)
61 ;;; ;; Add an horizontal toolbar on root at coordinates 0,0 pixels
63 ;;; (add-toolbar 0 0 :horiz 90 'top-middle-root-placement
64 ;;; '((clock 1) (label 50 "Plop") (clock-second 25) (clickable-clock 99))
69 ;;; ;; Add an horizontal toolbar on root at coordinates 0,0 pixels
71 ;;; (add-toolbar 0 0 :horiz 70 'bottom-middle-root-placement '((clock 1) (label 50 "Paf) (clock 99))
72 ;;; :autohide :motion)
75 ;;; ;; Add a vertical toolbar on root 0
77 ;;; (add-toolbar 0 nil :vert 60 'middle-left-root-placement '((clock 1) (label 50 "My label") (clock 90)))
80 ;;; ;; Add a vertical toolbar on root 1
82 ;;; (add-toolbar 1 nil :vert 70 'bottom-right-root-placement '((clock 1) (label 50) (clickable-clock 99)))
83 ;;; --------------------------------------------------------------------------
87 (format t
"Loading Toolbar code... ")
89 (defstruct toolbar root-x root-y root direction size thickness placement refresh-delay
90 autohide modules clickable hide-state font window gc border-size
)
92 (defstruct toolbar-module name pos display-fun click-fun args rect
)
94 (defparameter *toolbar-list
* nil
)
95 (defparameter *toolbar-module-list
* nil
)
97 (defconfig *default-toolbar
* '((clfswm-menu 1)
100 'Toolbar
"Default toolbar modules")
103 ;;; CONFIG - Toolbar window string colors
104 (defconfig *toolbar-window-font-string
* *default-font-string
*
105 'Toolbar
"Toolbar window font string")
106 (defconfig *toolbar-window-background
* "black"
107 'Toolbar
"Toolbar Window background color")
108 (defconfig *toolbar-window-foreground
* "green"
109 'Toolbar
"Toolbar Window foreground color")
110 (defconfig *toolbar-window-border
* "red"
111 'Toolbar
"Toolbar Window border color")
112 (defconfig *toolbar-default-border-size
* 0
113 'Toolbar
"Toolbar Window border size")
114 (defconfig *toolbar-window-transparency
* *default-transparency
*
115 'Toolbar
"Toolbar window background transparency")
116 (defconfig *toolbar-default-thickness
* 20
117 'Toolbar
"Toolbar default thickness")
118 (defconfig *toolbar-default-refresh-delay
* 30
119 'Toolbar
"Toolbar default refresh delay")
120 (defconfig *toolbar-default-autohide
* nil
121 'Toolbar
"Toolbar default autohide value")
122 (defconfig *toolbar-sensibility
* 3
123 'Toolbar
"Toolbar sensibility in pixels")
125 (defconfig *toolbar-window-placement
* 'top-left-placement
126 'Placement
"Toolbar window placement")
128 (defun toolbar-symbol-fun (name &optional
(type 'display
))
129 (create-symbol-in-package :clfswm
'toolbar- name
'-module- type
))
131 (defun toolbar-adjust-root-size (toolbar)
132 (unless (toolbar-autohide toolbar
)
133 (let ((root (toolbar-root toolbar
))
134 (placement-name (symbol-name (toolbar-placement toolbar
)))
135 (thickness (+ (toolbar-thickness toolbar
) (* 2 (toolbar-border-size toolbar
)))))
137 (case (toolbar-direction toolbar
)
138 (:horiz
(cond ((search "TOP" placement-name
)
139 (incf (root-y root
) thickness
)
140 (decf (root-h root
) thickness
))
141 ((search "BOTTOM" placement-name
)
142 (decf (root-h root
) thickness
))))
143 (t (cond ((search "LEFT" placement-name
)
144 (incf (root-x root
) thickness
)
145 (decf (root-w root
) thickness
))
146 ((search "RIGHT" placement-name
)
147 (decf (root-w root
) thickness
)))))))))
150 (defun toolbar-draw-text (toolbar pos1 pos2 text
)
151 "pos1: percent of toolbar, pos2: pixels in toolbar"
152 (labels ((horiz-text ()
153 (let* ((height (- (xlib:font-ascent
(toolbar-font toolbar
)) (xlib:font-descent
(toolbar-font toolbar
))))
154 (dy (truncate (+ pos2
(/ height
2))))
155 (width (xlib:text-width
(toolbar-font toolbar
) text
))
156 (pos (truncate (/ (* (- (xlib:drawable-width
(toolbar-window toolbar
)) width
) pos1
) 100))))
157 (xlib:draw-glyphs
*pixmap-buffer
* (toolbar-gc toolbar
) pos dy text
)
158 (values (+ pos
(xlib:drawable-x
(toolbar-window toolbar
)))
159 (xlib:drawable-y
(toolbar-window toolbar
))
161 (xlib:drawable-height
(toolbar-window toolbar
)))))
163 (let* ((width (xlib:max-char-width
(toolbar-font toolbar
)))
164 (dx (truncate (- pos2
(/ width
2))))
165 (dpos (xlib:max-char-ascent
(toolbar-font toolbar
)))
166 (height (* dpos
(length text
)))
167 (pos (+ (truncate (/ (* (- (xlib:drawable-height
(toolbar-window toolbar
)) height
168 (xlib:max-char-descent
(toolbar-font toolbar
)))
170 (xlib:font-ascent
(toolbar-font toolbar
)))))
171 (loop for c across text
173 do
(xlib:draw-glyphs
*pixmap-buffer
* (toolbar-gc toolbar
) dx
(+ pos
(* i dpos
)) (string c
)))
174 (values (xlib:drawable-x
(toolbar-window toolbar
))
175 (+ (- pos dpos
) (xlib:drawable-y
(toolbar-window toolbar
)))
176 (xlib:drawable-width
(toolbar-window toolbar
))
178 (case (toolbar-direction toolbar
)
179 (:horiz
(horiz-text))
180 (:vert
(vert-text)))))
183 (defun toolbar-module-text (toolbar module formatter
&rest text
)
184 "Print a formatted text at module position centered in toolbar"
185 (toolbar-draw-text toolbar
(toolbar-module-pos module
) (/ *toolbar-default-thickness
* 2)
186 (apply #'format nil formatter text
)))
190 (defun refresh-toolbar (toolbar)
191 (unless (toolbar-hide-state toolbar
)
192 (add-timer (toolbar-refresh-delay toolbar
)
194 (refresh-toolbar toolbar
))
196 (clear-pixmap-buffer (toolbar-window toolbar
) (toolbar-gc toolbar
))
197 (dolist (module (toolbar-modules toolbar
))
198 (when (fboundp (toolbar-module-display-fun module
))
199 (apply (toolbar-module-display-fun module
) toolbar module
(toolbar-module-args module
))))
200 (copy-pixmap-buffer (toolbar-window toolbar
) (toolbar-gc toolbar
))))
202 (defun toolbar-in-sensibility-zone-p (toolbar root-x root-y
)
203 (let* ((tb-win (toolbar-window toolbar
))
204 (win-x (xlib:drawable-x tb-win
))
205 (win-y (xlib:drawable-y tb-win
))
206 (width (xlib:drawable-width tb-win
))
207 (height (xlib:drawable-height tb-win
))
208 (tb-dir (toolbar-direction toolbar
) )
209 (placement-name (symbol-name (toolbar-placement toolbar
))))
210 (or (and (equal tb-dir
:horiz
) (search "TOP" placement-name
)
211 (<= root-y win-y
(+ root-y
*toolbar-sensibility
*))
212 (<= win-x root-x
(+ win-x width
)) (toolbar-autohide toolbar
))
213 (and (equal tb-dir
:horiz
) (search "BOTTOM" placement-name
)
214 (<= (+ win-y height
(- *toolbar-sensibility
*)) root-y
(+ win-y height
))
215 (<= win-x root-x
(+ win-x width
)) (toolbar-autohide toolbar
))
216 (and (equal tb-dir
:vert
) (search "LEFT" placement-name
)
217 (<= root-x win-x
(+ root-x
*toolbar-sensibility
*))
218 (<= win-y root-y
(+ win-y height
)) (toolbar-autohide toolbar
))
219 (and (equal tb-dir
:vert
) (search "RIGHT" placement-name
)
220 (<= (+ win-x width
(- *toolbar-sensibility
*)) root-x
(+ win-x width
))
221 (<= win-y root-y
(+ win-y height
)) (toolbar-autohide toolbar
)))))
223 (use-event-hook :exposure
)
224 (use-event-hook :button-press
)
225 (use-event-hook :motion-notify
)
226 (use-event-hook :leave-notify
)
229 (defun toolbar-add-exposure-hook (toolbar)
230 (define-event-hook :exposure
(window)
231 (when (and (xlib:window-p window
) (xlib:window-equal
(toolbar-window toolbar
) window
))
232 (refresh-toolbar toolbar
))))
234 (defun toolbar-add-hide-button-press-hook (toolbar)
235 (define-event-hook :button-press
(code root-x root-y
)
237 (let* ((tb-win (toolbar-window toolbar
)))
238 (when (toolbar-in-sensibility-zone-p toolbar root-x root-y
)
239 (if (toolbar-hide-state toolbar
)
241 (setf (toolbar-hide-state toolbar
) nil
)
243 (raise-window tb-win
)
244 (refresh-toolbar toolbar
))
247 (setf (toolbar-hide-state toolbar
) t
)))
248 (wait-mouse-button-release)
250 (exit-handle-event))))))
252 (defun toolbar-add-hide-motion-hook (toolbar)
253 (define-event-hook :motion-notify
(root-x root-y
)
254 (unless (compress-motion-notify)
255 (when (and (toolbar-hide-state toolbar
)
256 (toolbar-in-sensibility-zone-p toolbar root-x root-y
))
257 (map-window (toolbar-window toolbar
))
258 (raise-window (toolbar-window toolbar
))
259 (refresh-toolbar toolbar
)
260 (setf (toolbar-hide-state toolbar
) nil
)
261 (exit-handle-event)))))
263 (defun toolbar-add-hide-leave-hook (toolbar)
264 (define-event-hook :leave-notify
(root-x root-y
)
265 (when (and (not (toolbar-hide-state toolbar
))
266 (not (in-window (toolbar-window toolbar
) root-x root-y
)))
267 (hide-window (toolbar-window toolbar
))
268 (setf (toolbar-hide-state toolbar
) t
)
269 (exit-handle-event))))
272 (defun toolbar-add-clickable-module-hook (toolbar)
273 (define-event-hook :button-press
(code state root-x root-y
)
274 (when (and (in-window (toolbar-window toolbar
) root-x root-y
)
275 (not (toolbar-hide-state toolbar
)))
276 (dolist (module (toolbar-modules toolbar
))
277 (when (and (in-rectangle root-x root-y
(toolbar-module-rect module
))
278 (fboundp (toolbar-module-click-fun module
)))
279 (apply (toolbar-module-click-fun module
) toolbar module code state
280 (toolbar-module-args module
))
282 (exit-handle-event))))))
285 (defun define-toolbar-hooks (toolbar)
286 (toolbar-add-exposure-hook toolbar
)
287 (when (toolbar-clickable toolbar
)
288 (toolbar-add-clickable-module-hook toolbar
))
289 (case (toolbar-autohide toolbar
)
290 (:click
(toolbar-add-hide-button-press-hook toolbar
))
291 (:motion
(toolbar-add-hide-motion-hook toolbar
)
292 (toolbar-add-hide-leave-hook toolbar
))))
294 (defun set-clickable-toolbar (toolbar)
295 (dolist (module (toolbar-modules toolbar
))
296 (when (fboundp (toolbar-module-click-fun module
))
297 (setf (toolbar-clickable toolbar
) t
))))
301 (let ((windows-list nil
))
302 (defun is-toolbar-window-p (win)
303 (and (xlib:window-p win
) (member win windows-list
:test
'xlib
:window-equal
)))
305 (defun close-toolbar (toolbar)
306 (erase-timer :refresh-toolbar-window
)
307 (setf *never-managed-window-list
*
308 (remove (list #'is-toolbar-window-p nil
)
309 *never-managed-window-list
* :test
#'equal
))
310 (awhen (toolbar-gc toolbar
)
311 (xlib:free-gcontext it
))
312 (awhen (toolbar-window toolbar
)
313 (xlib:destroy-window it
))
314 (awhen (toolbar-font toolbar
)
315 (xlib:close-font it
))
316 (xlib:display-finish-output
*display
*)
317 (setf (toolbar-window toolbar
) nil
318 (toolbar-gc toolbar
) nil
319 (toolbar-font toolbar
) nil
))
321 (defun open-toolbar (toolbar)
322 (let ((root (root (toolbar-root-x toolbar
) (toolbar-root-y toolbar
))))
324 (setf (toolbar-root toolbar
) root
)
325 (let ((*get-current-root-fun
* (lambda () root
)))
326 (setf (toolbar-font toolbar
) (xlib:open-font
*display
* *toolbar-window-font-string
*))
327 (let* ((width (if (equal (toolbar-direction toolbar
) :horiz
)
328 (round (/ (* (root-w root
) (toolbar-size toolbar
)) 100))
329 (toolbar-thickness toolbar
)))
330 (height (if (equal (toolbar-direction toolbar
) :horiz
)
331 (toolbar-thickness toolbar
)
332 (round (/ (* (root-h root
) (toolbar-size toolbar
)) 100)))))
333 (with-placement ((toolbar-placement toolbar
) x y width height
(toolbar-border-size toolbar
))
334 (setf (toolbar-window toolbar
) (xlib:create-window
:parent
*root
*
339 :background
(get-color *toolbar-window-background
*)
340 :border-width
(toolbar-border-size toolbar
)
341 :border
(when (plusp (toolbar-border-size toolbar
))
342 (get-color *toolbar-window-border
*))
343 :colormap
(xlib:screen-default-colormap
*screen
*)
344 :event-mask
'(:exposure
:key-press
:leave-window
346 (toolbar-gc toolbar
) (xlib:create-gcontext
:drawable
(toolbar-window toolbar
)
347 :foreground
(get-color *toolbar-window-foreground
*)
348 :background
(get-color *toolbar-window-background
*)
349 :font
(toolbar-font toolbar
)
351 (push (toolbar-window toolbar
) windows-list
)
352 (setf (window-transparency (toolbar-window toolbar
)) *toolbar-window-transparency
*)
353 (push (list #'is-toolbar-window-p nil
) *never-managed-window-list
*)
354 (map-window (toolbar-window toolbar
))
355 (raise-window (toolbar-window toolbar
))
356 (refresh-toolbar toolbar
)
357 (when (toolbar-autohide toolbar
)
358 (hide-window (toolbar-window toolbar
))
359 (setf (toolbar-hide-state toolbar
) t
))
360 (xlib:display-finish-output
*display
*)
361 (set-clickable-toolbar toolbar
)
362 (define-toolbar-hooks toolbar
))))))))
365 (defun open-all-toolbars ()
367 (dolist (toolbar *toolbar-list
*)
368 (open-toolbar toolbar
))
369 (dolist (toolbar *toolbar-list
*)
370 (toolbar-adjust-root-size toolbar
)))
372 (defun close-all-toolbars ()
373 (dolist (toolbar *toolbar-list
*)
374 (close-toolbar toolbar
))
377 (defun create-toolbar-modules (modules)
378 (loop for mod in modules
379 collect
(make-toolbar-module :name
(first mod
)
381 :display-fun
(toolbar-symbol-fun (first mod
))
382 :click-fun
(toolbar-symbol-fun (first mod
) 'click
)
387 (defun add-toolbar (root-x root-y direction size placement modules
388 &key
(autohide *toolbar-default-autohide
*)
389 (thickness *toolbar-default-thickness
*)
390 (refresh-delay *toolbar-default-refresh-delay
*)
391 (border-size *toolbar-default-border-size
*))
393 root-x, root-y: root coordinates or if root-y is nil, root-x is the nth root in root-list.
394 direction: one of :horiz or :vert
395 placement: same argument as with-placement macro
396 modules: list of modules: a list of module name, position in percent and arguments.
397 0%=left/up <-> 100%=right/down.
398 Example: '((clock 1) (label 50 \"My label\") (clickable-clock 90))
399 size: toolbar size in percent of root size
400 thickness: toolbar height for horizontal toolbar or width for vertical one
401 autohide: one of nil, :click, or :motion
402 refresh-delay: refresh delay for toolbar in seconds
403 border-size: toolbar window border size"
404 (let ((toolbar (make-toolbar :root-x root-x
:root-y root-y
405 :direction direction
:size size
409 :refresh-delay refresh-delay
410 :border-size border-size
411 :modules
(create-toolbar-modules modules
))))
412 (push toolbar
*toolbar-list
*)
416 (add-hook *init-hook
* 'open-all-toolbars
)
417 (add-hook *close-hook
* 'close-all-toolbars
)
420 (defun set-toolbar-module-rectangle (module x y width height
)
421 (unless (toolbar-module-rect module
)
422 (setf (toolbar-module-rect module
) (make-rectangle)))
423 (setf (rectangle-x (toolbar-module-rect module
)) x
424 (rectangle-y (toolbar-module-rect module
)) y
425 (rectangle-width (toolbar-module-rect module
)) width
426 (rectangle-height (toolbar-module-rect module
)) height
))
428 (defmacro with-set-toolbar-module-rectangle
((module) &body body
)
429 (let ((x (gensym)) (y (gensym)) (width (gensym)) (height (gensym)))
430 `(multiple-value-bind (,x
,y
,width
,height
)
432 (set-toolbar-module-rectangle ,module
,x
,y
,width
,height
))))
436 (defmacro define-toolbar-module
((name &rest args
) &body body
)
437 (let ((symbol-fun (toolbar-symbol-fun name
)))
439 (pushnew ',name
*toolbar-module-list
*)
440 (defun ,symbol-fun
(toolbar module
,@(when args
`(&optional
,@args
)))
443 (defmacro define-toolbar-module-click
((name &rest args
) &body body
)
444 (let ((symbol-fun (toolbar-symbol-fun name
'click
)))
446 (pushnew ',name
*toolbar-module-list
*)
447 (defun ,symbol-fun
(toolbar module code state
,@(when args
`(&optional
,@args
)))
451 (defun list-toolbar-modules (&optional
(stream t
))
452 "List all toolbar modules"
453 (format stream
"Toolbar modules availables:~%")
454 (dolist (module (reverse *toolbar-module-list
*))
455 (format stream
" Module: ~A~%" module
)
456 (when (fboundp (toolbar-symbol-fun module
))
457 (format stream
" ~A~%" (documentation (toolbar-symbol-fun module
) 'function
)))
458 (when (fboundp (toolbar-symbol-fun module
'click
))
459 (format stream
" On click: ~A~%" (documentation (toolbar-symbol-fun module
'click
) 'function
)))))
462 ;;; Modules definitions
468 (define-toolbar-module (clock)
470 (multiple-value-bind (s m h
)
473 (toolbar-module-text toolbar module
"~2,'0D:~2,'0D" h m
)))
476 ;;; Clock module with seconds
478 (define-toolbar-module (clock-second)
479 "A clock module with seconds"
480 (multiple-value-bind (s m h
)
482 (toolbar-module-text toolbar module
"~2,'0D:~2,'0D:~2,'0D" h m s
)))
488 (define-toolbar-module (label text
)
489 "(text) - Display a text in toolbar"
490 (toolbar-module-text toolbar module
(or text
"Empty")))
493 ;;; Clickable label module
495 (define-toolbar-module (clickable-label text action
)
496 "(text action) - Display a clickable text in toolbar"
497 (declare (ignore action
))
498 (with-set-toolbar-module-rectangle (module)
499 (toolbar-module-text toolbar module
(or text
"Empty"))))
501 (define-toolbar-module-click (clickable-label text action
)
502 "Call the function 'action'"
503 (declare (ignore text
))
505 (funcall action toolbar module code state
)))
508 ;;; Clickable clock module
510 (define-toolbar-module (clickable-clock)
511 "A clickable clock module"
512 (multiple-value-bind (s m h
)
515 (with-set-toolbar-module-rectangle (module)
516 (toolbar-module-text toolbar module
"~2,'0D:~2,'0D" h m
))))
519 (defconfig *toolbar-clock-action
* "xclock -analog"
520 'toolbar
"Toolbar clickable clock module action on click")
522 (define-toolbar-module-click (clickable-clock)
523 "Start an external clock"
524 (declare (ignore toolbar module state
))
526 (do-shell *toolbar-clock-action
*)))
533 ;;; CLFSWM menu module
535 (define-toolbar-module (clfswm-menu text placement
)
536 "(text placement) - Display an entry for the CLFSWM menu"
537 (declare (ignore placement
))
538 (with-set-toolbar-module-rectangle (module)
539 (toolbar-module-text toolbar module
(or text
"CLFSWM"))))
541 (define-toolbar-module-click (clfswm-menu text placement
)
542 "Open the CLFSWM main menu"
543 (declare (ignore text code state toolbar module
))
544 (let ((*info-mode-placement
* (or placement
*info-mode-placement
*)))
550 (define-toolbar-module (cpu)
551 "Display the CPU usage (slow methode)"
552 (toolbar-module-text toolbar module
"CPU:~A%" (cpu-usage)))
558 (define-toolbar-module (mem)
559 "Display the memory usage (slow methode)"
560 (multiple-value-bind (used total
)
562 (toolbar-module-text toolbar module
"Mem:~A%" (round (* (/ used total
) 100.0)))))
569 (define-toolbar-module (bat)
570 "Display the battery usage (slow methode)"
571 (let* ((bat (battery-usage))
572 (alert (battery-alert-string bat
)))
573 (toolbar-module-text toolbar module
"Bat:~A~A%~A" alert bat alert
)))
578 ;;; System usage - Battery, CPU and Memory usage all in one
580 (define-toolbar-module (system-usage (poll-delay 10))
581 "Display system usage: CPU, Memory and Battery (poll methode)"
582 (multiple-value-bind (cpu used total bat
)
583 (system-usage-poll poll-delay
)
584 (let ((alert (battery-alert-string bat
)))
585 (toolbar-module-text toolbar module
"Bat:~A~A%~A CPU:~A% Mem:~A%"
587 (round (* (/ used total
) 100))))))
590 ;;; CPU and Memory usage - CPU and Memory usage
592 (define-toolbar-module (system-cpu-mem (poll-delay 10))
593 "Display system usage: CPU and Memory (poll methode)"
594 (multiple-value-bind (cpu used total
)
595 (system-usage-poll poll-delay
)
596 (toolbar-module-text toolbar module
"CPU:~A% Mem:~A%"
598 (round (* (/ used total
) 100)))))