From bc61218f922337e70c379b05d3b61ceba54b34a5 Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Thu, 11 Mar 2021 11:22:45 +0000 Subject: [PATCH] A bash script for catching when the server is offline --- README.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a391123..4973baf 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,12 @@ 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. + +### Additional Configuration + You can also display an icon specific to the clocked tasks category with the `format-icons` key: ```json @@ -62,9 +68,15 @@ If you run emacs in this mode you can also eval commands on click, middle click ``` -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 want the taskbar to show nothing or some other content if the emacs server is not running then you need to write a short bash script to catch when the emacsclient command returns a non-zero exit code. An example of this is: + +```bash +#!/bin/bash + +json=$(emacsclient --eval '(org-clock-waybar-ouptut-task)' 2> /dev/null) +status=$? +[ $status -eq 0 ] && echo $(echo $json | jq fromjson --unbuffered --compact-output) || echo "" +``` ## Customization