forked from gergely/org-clock-waybar
Factor out the title and category queries to separate functions
This commit is contained in:
parent
bc61218f92
commit
eb03af79d9
@ -64,6 +64,14 @@
|
|||||||
'emacs-mule)
|
'emacs-mule)
|
||||||
"Coding system of the file `org-clock-waybar-filename'.")
|
"Coding system of the file `org-clock-waybar-filename'.")
|
||||||
|
|
||||||
|
(defsubst org-clock-waybar--get-task-title (task)
|
||||||
|
"Get the title of TASK."
|
||||||
|
(when task (substring-no-properties task)))
|
||||||
|
|
||||||
|
(defsubst org-clock-waybar--get-task-category (task)
|
||||||
|
"Get the category of TASK."
|
||||||
|
(when task (get-text-property 0 'org-category task)))
|
||||||
|
|
||||||
(defun org-clock-waybar-tooltip ()
|
(defun org-clock-waybar-tooltip ()
|
||||||
"The default tooltip to send to waybar."
|
"The default tooltip to send to waybar."
|
||||||
(when org-clock-current-task
|
(when org-clock-current-task
|
||||||
@ -84,18 +92,16 @@ If CLOCKING-OUT is non-nil, `org-clock-current-task' will be treated as if it
|
|||||||
were nil; this is required because `org-clock-out' calls the hook functions
|
were nil; this is required because `org-clock-out' calls the hook functions
|
||||||
before setting `org-clock-current-task' to nil."
|
before setting `org-clock-current-task' to nil."
|
||||||
(let* ((task (if clocking-out nil org-clock-current-task))
|
(let* ((task (if clocking-out nil org-clock-current-task))
|
||||||
(category (when task (get-text-property 0 'org-category task)))
|
(category (org-clock-waybar--get-task-title task))
|
||||||
(title (when task (substring-no-properties task)))
|
(title (org-clock-waybar--get-task-category task))
|
||||||
(tooltip (org-clock-waybar-tooltip))
|
(tooltip (org-clock-waybar-tooltip))
|
||||||
(output (json-new-object)))
|
(output (json-new-object)))
|
||||||
(setq output (json-add-to-object
|
(setq output (json-add-to-object
|
||||||
output
|
output
|
||||||
"text"
|
"text"
|
||||||
(if title
|
(or title org-clock-waybar-not-clocked-in-text)))
|
||||||
title
|
(setq output (json-add-to-object output "alt" (or category "")))
|
||||||
org-clock-waybar-not-clocked-in-text)))
|
(setq output (json-add-to-object output "tooltip" (or tooltip "")))
|
||||||
(setq output (json-add-to-object output "alt" (if category category "")))
|
|
||||||
(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 "class" ""))
|
||||||
(setq output (json-add-to-object output "percentage" ""))
|
(setq output (json-add-to-object output "percentage" ""))
|
||||||
(json-encode output)))
|
(json-encode output)))
|
||||||
|
Loading…
Reference in New Issue
Block a user