Add the org-clock-waybar-output-task function
It outputs the generated JSON string to the standard output so it can be used directly from the command line, e.g. using `emacsclient`.
This commit is contained in:
		
							
								
								
									
										24
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								README.md
									
									
									
									
									
								
							| @@ -6,13 +6,15 @@ Put `org-clock-waybar.el` somewhere in your `load-path`, and `(require 'org-cloc | ||||
|  | ||||
| MELPA version may come soon. | ||||
|  | ||||
| You can set the file to be written by customizing `org-clock-waybar-filename`; it defaults to `$XDG_CACHE_HOME/waybar-current-task.json` (`$XDG_CACHE_HOME` defaults to `$HOME/.cache` on XDG compatible systems, like Linux.) | ||||
| You can set the file to be written by customizing `org-clock-waybar-filename`; it defaults to | ||||
| `$XDG_CACHE_HOME/waybar-current-task.json` (`$XDG_CACHE_HOME` defaults to `$HOME/.cache` on XDG | ||||
| compatible systems, like Linux.) | ||||
|  | ||||
| ## Waybar configuration | ||||
|  | ||||
| To add the current task to Waybar, add this snippet to your config: | ||||
|  | ||||
| ``` | ||||
| ```json | ||||
| "custom/org": { | ||||
|   "format": " {}", | ||||
|   "return-type": "json", | ||||
| @@ -21,7 +23,23 @@ 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. | ||||
| 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.  In this case, no output file | ||||
| will be written.: | ||||
|  | ||||
| ```json | ||||
| "custom/org": { | ||||
|   "format": " {}", | ||||
|   "return-type": "json", | ||||
|   "restart-interval": 5, | ||||
|   "exec": "emacsclient --eval '(org-clock-waybar-ouptut-task)'" | ||||
| } | ||||
|  | ||||
| ``` | ||||
|  | ||||
| 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 | ||||
|  | ||||
|   | ||||
| @@ -95,6 +95,14 @@ value of `org-clock-waybar-not-clocked-in-text'." | ||||
|     (insert (org-clock-waybar--get-clocked-task-json)) | ||||
|     (write-file org-clock-waybar-filename))) | ||||
|  | ||||
| (defun org-clock-waybar-ouptut-task () | ||||
|   "Output the current task in JSON format Waybar can understand. | ||||
|  | ||||
| This function is ought to be used via Emacsclient: | ||||
|  | ||||
| emacsclient --eval '(org-clock-waybar-output-task)'" | ||||
|   (print (org-clock-waybar--get-clocked-task-json))) | ||||
|  | ||||
| (defun org-clock-waybar-setup () | ||||
|   "Setup org-clock-waybar. | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user