Add more config options and a tooltip

This commit is contained in:
2021-03-11 15:50:47 +00:00
parent 4a3c4b549e
commit 92f896af05
2 changed files with 40 additions and 7 deletions

View File

@@ -64,6 +64,15 @@
'emacs-mule)
"Coding system of the file `org-clock-waybar-filename'.")
(defun org-clock-waybar-tooltip ()
"The default tooltip to send to waybar."
(when org-clock-current-task
(let ((clocked-time (org-clock-get-clocked-time)))
(format "%s: %s (%s)"
(org-clock-waybar-alt)
(org-clock-waybar-text)
(org-duration-from-minutes clocked-time)))))
(defun org-clock-waybar--get-clocked-task-json (&optional clocking-out)
"Get the currently clocked-in tasks data as a stringified JSON object.
@@ -77,6 +86,7 @@ before setting `org-clock-current-task' to nil."
(let* ((task (if clocking-out nil org-clock-current-task))
(category (when task (get-text-property 0 'org-category task)))
(title (when task (substring-no-properties task)))
(tooltip (org-clock-waybar-tooltip))
(output (json-new-object)))
(setq output (json-add-to-object
output
@@ -85,7 +95,7 @@ before setting `org-clock-current-task' to nil."
title
org-clock-waybar-not-clocked-in-text)))
(setq output (json-add-to-object output "alt" (if category category "")))
(setq output (json-add-to-object output "tooltip" ""))
(setq output (json-add-to-object output "tooltip" (if tooltip tooltip "")))
(setq output (json-add-to-object output "class" ""))
(setq output (json-add-to-object output "percentage" ""))
(json-encode output)))