Make the "Not clocked in" text customizable

This commit is contained in:
Gergely Polonkai 2021-03-11 06:14:48 +01:00
parent d3d80e6e38
commit 5d97d022c7
No known key found for this signature in database
GPG Key ID: 2D2885533B869ED4
2 changed files with 18 additions and 3 deletions

View File

@ -22,3 +22,7 @@ To add the current task to Waybar, add this snippet to your config:
```
Then, add `custom/org` to `modules-left`/`modules-center`/`module-right` if your bars configuration. You can find a minimal working configuration in the [`examples`](./examples) directory.
## Customization
To see a list of configurable parts, use `M-x customize-group <RET> org-clock-waybar`.

View File

@ -52,6 +52,12 @@
:type 'string
:group 'org-clock-waybar)
(defcustom org-clock-waybar-not-clocked-in-text
"Not clocked in"
"Text to display when not clocked in on any task."
:type 'string
:group 'org-clock-waybar)
(defconst org-clock-waybar-filename-coding-system
(if (coding-system-p 'utf-8-emacs)
'utf-8-emacs
@ -62,15 +68,20 @@
"Save the currently clocked-in tasks data to BUFFER.
The output is in JSON format constructed in a way so Waybar can process it.
If there is no clocked in task, alt becomes empty and text will be set to
'Not clocked in'."
If there is no clocked in task, alt becomes empty and text will be set to the
value of `org-clock-waybar-not-clocked-in-text'."
(let ((category (when org-clock-current-task
(get-text-property 0 'org-category org-clock-current-task)))
(title (when org-clock-current-task
(substring-no-properties org-clock-current-task)))
(output (json-new-object)))
(with-current-buffer buffer
(setq output (json-add-to-object output "text" (if title title "Not clocked in")))
(setq output (json-add-to-object
output
"text"
(if title
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 "class" ""))