diff options
Diffstat (limited to 'mac/.config/sketchybar.mon/sketchybar/helper/helper.c')
| -rw-r--r-- | mac/.config/sketchybar.mon/sketchybar/helper/helper.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/mac/.config/sketchybar.mon/sketchybar/helper/helper.c b/mac/.config/sketchybar.mon/sketchybar/helper/helper.c new file mode 100644 index 0000000..71c3038 --- /dev/null +++ b/mac/.config/sketchybar.mon/sketchybar/helper/helper.c @@ -0,0 +1,31 @@ +#include "cpu.h" +#include "sketchybar.h" + +struct cpu g_cpu; + +void handler(env env) { + // Environment variables passed from sketchybar can be accessed as seen below + char* name = env_get_value_for_key(env, "NAME"); + char* sender = env_get_value_for_key(env, "SENDER"); + char* info = env_get_value_for_key(env, "INFO"); + char* selected = env_get_value_for_key(env, "SELECTED"); + + if ((strcmp(name, "cpu.percent") == 0)) { + // CPU graph updates + cpu_update(&g_cpu); + + if (strlen(g_cpu.command) > 0) sketchybar(g_cpu.command); + } +} + +int main (int argc, char** argv) { + cpu_init(&g_cpu); + + if (argc < 2) { + printf("Usage: helper \"<bootstrap name>\"\n"); + exit(1); + } + + event_server_begin(handler, argv[1]); + return 0; +} |
