X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=i3status.c;h=915cbccdb33be9f72fd73754c4fae51033bb42ae;hb=1c2517a3998385dbfca0559aca3ba7e72b5c216c;hp=b2b1714508cddacd792ed82a8947d0a6aec4638e;hpb=12b1bfa9b8485de88b0bda82821c021aee197673;p=i3%2Fi3status diff --git a/i3status.c b/i3status.c index b2b1714..915cbcc 100644 --- a/i3status.c +++ b/i3status.c @@ -3,7 +3,7 @@ * * i3status – Generates a status line for dzen2 or xmobar * - * Copyright © 2008-2011 Michael Stapelberg and contributors + * Copyright © 2008-2012 Michael Stapelberg and contributors * Copyright © 2009 Thorsten Toepper * Copyright © 2010 Axel Wagner * Copyright © 2010 Fernando Tarlá Cardoso Lemos @@ -29,6 +29,7 @@ #include #include +#include #include "i3status.h" @@ -120,7 +121,7 @@ static char *resolve_tilde(const char *path) { return result; } -static char *get_config_path() { +static char *get_config_path(void) { char *xdg_config_home, *xdg_config_dirs, *config_path; /* 1: check the traditional path under the home directory */ @@ -213,6 +214,8 @@ int main(int argc, char *argv[]) { cfg_opt_t battery_opts[] = { CFG_STR("format", "%status %percentage %remaining", CFGF_NONE), CFG_STR("path", "/sys/class/power_supply/BAT%d/uevent", CFGF_NONE), + CFG_INT("low_threshold", 30, CFGF_NONE), + CFG_STR("threshold_type", "time", CFGF_NONE), CFG_BOOL("last_full_capacity", false, CFGF_NONE), CFG_END() }; @@ -295,11 +298,11 @@ int main(int argc, char *argv[]) { if ((char)o == 'c') configfile = optarg; else if ((char)o == 'h') { - printf("i3status " VERSION " © 2008-2011 Michael Stapelberg and contributors\n" + printf("i3status " VERSION " © 2008-2012 Michael Stapelberg and contributors\n" "Syntax: %s [-c ] [-h] [-v]\n", argv[0]); return 0; } else if ((char)o == 'v') { - printf("i3status " VERSION " © 2008-2011 Michael Stapelberg and contributors\n"); + printf("i3status " VERSION " © 2008-2012 Michael Stapelberg and contributors\n"); return 0; } @@ -346,7 +349,11 @@ int main(int argc, char *argv[]) { || !valid_color(cfg_getstr(cfg_general, "color_separator"))) die("Bad color format"); +#if YAJL_MAJOR >= 2 yajl_gen json_gen = yajl_gen_alloc(NULL); +#else + yajl_gen json_gen = yajl_gen_alloc(NULL, NULL); +#endif if (output_format == O_I3BAR) { /* Initialize the i3bar protocol. See i3/docs/i3bar-protocol @@ -408,7 +415,7 @@ int main(int argc, char *argv[]) { CASE_SEC_TITLE("battery") { SEC_OPEN_MAP("battery"); - print_battery_info(json_gen, buffer, atoi(title), cfg_getstr(sec, "path"), cfg_getstr(sec, "format"), cfg_getbool(sec, "last_full_capacity")); + print_battery_info(json_gen, buffer, atoi(title), cfg_getstr(sec, "path"), cfg_getstr(sec, "format"), cfg_getint(sec, "low_threshold"), cfg_getstr(sec, "threshold_type"), cfg_getbool(sec, "last_full_capacity")); SEC_CLOSE_MAP; } @@ -466,7 +473,11 @@ int main(int argc, char *argv[]) { if (output_format == O_I3BAR) { yajl_gen_array_close(json_gen); const unsigned char *buf; +#if YAJL_MAJOR >= 2 size_t len; +#else + unsigned int len; +#endif yajl_gen_get_buf(json_gen, &buf, &len); write(STDOUT_FILENO, buf, len); yajl_gen_clear(json_gen);