forked from gergely/org-clock-waybar
Add more config options and a tooltip
This commit is contained in:
parent
4a3c4b549e
commit
92f896af05
35
README.md
35
README.md
@ -23,19 +23,42 @@ To add the current task to Waybar, add this snippet to your config:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can also display an icon specific to the clocked tasks category with the `format-icons` key:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"custom/org": {
|
||||||
|
"format": "{icon} {}",
|
||||||
|
"return-type": "json",
|
||||||
|
"restart-interval": 1,
|
||||||
|
"format-icons": {
|
||||||
|
"refile": "",
|
||||||
|
"ToDo": "",
|
||||||
|
},
|
||||||
|
"exec": "cat /home/yourusername/.cache/waybar-current-task.json"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
If you use Emacs as a daemon (e.g. starting it as `emacs --daemon` or calling `(server-start)`),
|
If you use Emacs as a daemon (e.g. starting it as `emacs --daemon` or calling `(server-start)`),
|
||||||
you can change the `exec` command to invoke `emacsclient` directly. Note that, since Emacsclient
|
you can change the `exec` command to invoke `emacsclient` directly. Note that, since Emacsclient
|
||||||
can’t actually write stuff to the terminal, it will output an Emacs string full of backslashes
|
can’t actually write stuff to the terminal, it will output an Emacs string full of backslashes
|
||||||
(see [this Emacs SE answer for details](https://emacs.stackexchange.com/a/28668/507)); thus, you
|
(see [this Emacs SE answer for details](https://emacs.stackexchange.com/a/28668/507)); thus, you
|
||||||
have to pipe the output through `jq fromjson`. In this case, no output file will be written.:
|
have to pipe the output through `jq fromjson`.
|
||||||
|
|
||||||
|
If you run emacs in this mode you can also eval commands on click, middle click or scroll.:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"custom/org": {
|
"custom/org": {
|
||||||
"format": " {}",
|
"format": "{icon} {}",
|
||||||
"return-type": "json",
|
"return-type": "json",
|
||||||
"restart-interval": 5,
|
"restart-interval": 1,
|
||||||
"exec": "emacsclient --eval '(org-clock-waybar-ouptut-task)' | jq fromjson"
|
"format-icons": {
|
||||||
}
|
"refile": "",
|
||||||
|
"ToDo": "",
|
||||||
|
},
|
||||||
|
"exec": "emacsclient --eval '(org-clock-waybar-ouptut-task)' | jq fromjson --unbuffered --compact-output",
|
||||||
|
"on-click": "emacsclient --eval '(org-clock-out)'",
|
||||||
|
"on-middle-click": "emacsclient --eval '(org-clock-in-last)'",
|
||||||
|
},
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -64,6 +64,15 @@
|
|||||||
'emacs-mule)
|
'emacs-mule)
|
||||||
"Coding system of the file `org-clock-waybar-filename'.")
|
"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)
|
(defun org-clock-waybar--get-clocked-task-json (&optional clocking-out)
|
||||||
"Get the currently clocked-in task’s data as a stringified JSON object.
|
"Get the currently clocked-in task’s 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))
|
(let* ((task (if clocking-out nil org-clock-current-task))
|
||||||
(category (when task (get-text-property 0 'org-category task)))
|
(category (when task (get-text-property 0 'org-category task)))
|
||||||
(title (when task (substring-no-properties task)))
|
(title (when task (substring-no-properties task)))
|
||||||
|
(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
|
||||||
@ -85,7 +95,7 @@ before setting `org-clock-current-task' to nil."
|
|||||||
title
|
title
|
||||||
org-clock-waybar-not-clocked-in-text)))
|
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 "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 "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