From 5d97d022c7bef972a44b5469d2f9db7155966778 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Thu, 11 Mar 2021 06:14:48 +0100 Subject: [PATCH] Make the "Not clocked in" text customizable --- README.md | 4 ++++ org-clock-waybar.el | 17 ++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 39c79a1..9b86183 100644 --- a/README.md +++ b/README.md @@ -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 bar’s 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 org-clock-waybar`. diff --git a/org-clock-waybar.el b/org-clock-waybar.el index c3d3986..79ae241 100644 --- a/org-clock-waybar.el +++ b/org-clock-waybar.el @@ -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 task’s 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" ""))