summaryrefslogtreecommitdiff
path: root/src/gizmo/wasp-heartrate.el
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2025-11-07 00:20:02 -0500
committerLLLL Colonq <llll@colonq>2025-11-07 00:20:02 -0500
commitcf266a56f30daae8b9af7c9bc3267c61b1973192 (patch)
treef365939f712973840ff19d9265c552af820cd1ef /src/gizmo/wasp-heartrate.el
parent3d31c488fb06e9937964041f4d83d0cb1c9699ab (diff)
Update
Diffstat (limited to 'src/gizmo/wasp-heartrate.el')
-rw-r--r--src/gizmo/wasp-heartrate.el39
1 files changed, 10 insertions, 29 deletions
diff --git a/src/gizmo/wasp-heartrate.el b/src/gizmo/wasp-heartrate.el
index 91e758fd..fa27d64d 100644
--- a/src/gizmo/wasp-heartrate.el
+++ b/src/gizmo/wasp-heartrate.el
@@ -9,23 +9,13 @@
(require 'wasp-utils)
(require 'wasp-chat)
-(defun w/get-load ()
- "Get the current CPU load."
- (let ((res (shell-command-to-string "uptime")))
- (string-to-number (s-trim (car (s-split "," (cadr (s-split "load average:" res))))))))
-
-(defun w/get-disk-usage (disk)
- "Get the current usage percent for DISK"
- (let ((res (shell-command-to-string (format "df %s" disk))))
- (string-to-number (s-chop-suffix "%" (nth 4 (s-split " " (cadr (s-lines res)) t))))))
-
-(defun w/get-heartrate ()
+(defun w/heartrate ()
"Get the streamer's heart rate."
- (* 100 (w/get-load)))
+ (* 100 (w/cpu-load)))
-(defun w/get-blood-pressure ()
+(defun w/heartrate-blood-pressure ()
"Get the streamer's blood pressure."
- (format "%s/%s" (w/get-disk-usage "/") (w/get-disk-usage "/home")))
+ (format "%s/%s" (w/disk-usage "/") (w/disk-usage "/home")))
(defface w/heartrate-big
'((t
@@ -52,32 +42,23 @@
:group 'w
(setq-local cursor-type nil))
-(defun w/get-heartrate-buffer ()
+(defun w/heartrate-get-buffer ()
"Return the heartrate buffer."
(unless (get-buffer w/heartrate-buffer)
(with-current-buffer (get-buffer-create w/heartrate-buffer)
(w/heartrate-mode)))
(get-buffer w/heartrate-buffer))
-(defun w/render-heartrate ()
+(defun w/heartrate-update ()
"Render the heartrate buffer."
- (with-current-buffer (w/get-heartrate-buffer)
+ (with-current-buffer (w/heartrate-get-buffer)
(setq-local cursor-type nil)
(let* ((inhibit-read-only t))
(erase-buffer)
- (w/write-line (format "%3d bpm" (w/get-heartrate)) 'w/heartrate-big)
- (w/write-line (format "blood pressure: %s" (w/get-blood-pressure)) 'w/heartrate-small)
+ (w/write-line (format "%3d bpm" (w/heartrate)) 'w/heartrate-big)
+ (w/write-line (format "blood pressure: %s" (w/heartrate-blood-pressure)) 'w/heartrate-small)
(w/write (format "arbitrary counter: %s times" w/chat-bpm-count) 'w/heartrate-small))))
-
-(defvar w/heartrate-timer nil)
-(defun w/run-heartrate-timer ()
- "Run the heartrate timer."
- (when w/heartrate-timer
- (cancel-timer w/heartrate-timer))
- (w/render-heartrate)
- (setq
- w/heartrate-timer
- (run-with-timer 1 nil #'w/run-heartrate-timer)))
+(add-hook 'w/gizmo-update-hook #'w/heartrate-update)
(provide 'wasp-heartrate)
;;; wasp-heartrate.el ends here