Factor out clocked-out title generation to get-task-title

This commit is contained in:
Gergely Polonkai 2021-03-12 17:18:43 +01:00
parent 2d820dbf87
commit 1dafd1306e
No known key found for this signature in database
GPG Key ID: 2D2885533B869ED4
1 changed files with 4 additions and 5 deletions

View File

@ -66,7 +66,9 @@
(defsubst org-clock-waybar-get-task-title ()
"Get the title of TASK."
(when (org-clocking-p) (substring-no-properties org-clock-current-task)))
(if (org-clocking-p)
(substring-no-properties org-clock-current-task)
org-clock-waybar-not-clocked-in-text))
(defsubst org-clock-waybar-get-task-category ()
"Get the category of TASK."
@ -99,10 +101,7 @@ value of `org-clock-waybar-not-clocked-in-text'."
(tooltip (org-clock-waybar-get-tooltip))
(class (org-clock-waybar-get-tags))
(output (json-new-object)))
(setq output (json-add-to-object
output
"text"
(or title org-clock-waybar-not-clocked-in-text)))
(setq output (json-add-to-object output "text" (or title "")))
(setq output (json-add-to-object output "alt" (or category "")))
(setq output (json-add-to-object output "tooltip" (or tooltip "")))
(setq output (json-add-to-object output "class" (or class "")))