From 625518acd7c62acde2d6d150272fa17a45eb3ce9 Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Sun, 17 Jan 2016 18:05:11 +0100 Subject: Add support for custom commands Add the cmd option in the config that runs a shell command. --- i3status.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'i3status.c') diff --git a/i3status.c b/i3status.c index b02b71a..3ddef09 100644 --- a/i3status.c +++ b/i3status.c @@ -506,6 +506,12 @@ int main(int argc, char *argv[]) { CFG_CUSTOM_SEP_BLOCK_WIDTH_OPT, CFG_END()}; + cfg_opt_t cmd_opts[] = { + CFG_STR("cmd", "echo 'hello world'", CFGF_NONE), + CFG_CUSTOM_ALIGN_OPT, + CFG_CUSTOM_MIN_WIDTH_OPT, + CFG_END()}; + cfg_opt_t opts[] = { CFG_STR_LIST("order", "{}", CFGF_NONE), CFG_SEC("general", general_opts, CFGF_NONE), @@ -519,6 +525,7 @@ int main(int argc, char *argv[]) { CFG_SEC("volume", volume_opts, CFGF_TITLE | CFGF_MULTI), CFG_SEC("ipv6", ipv6_opts, CFGF_NONE), CFG_SEC("time", time_opts, CFGF_NONE), + CFG_SEC("cmd", cmd_opts, CFGF_TITLE | CFGF_MULTI), CFG_SEC("tztime", tztime_opts, CFGF_TITLE | CFGF_MULTI), CFG_SEC("ddate", ddate_opts, CFGF_NONE), CFG_SEC("load", load_opts, CFGF_NONE), @@ -828,6 +835,12 @@ int main(int argc, char *argv[]) { print_file_contents(json_gen, buffer, title, cfg_getstr(sec, "path"), cfg_getstr(sec, "format"), cfg_getstr(sec, "format_bad"), cfg_getint(sec, "max_characters")); SEC_CLOSE_MAP; } + + CASE_SEC("cmd") { + SEC_OPEN_MAP("cmd"); + print_cmd(json_gen, buffer, cfg_getstr(sec, "cmd")); + SEC_CLOSE_MAP; + } } if (output_format == O_I3BAR) { yajl_gen_array_close(json_gen); -- cgit v1.2.3