]> git.sur5r.net Git - i3/i3status/commitdiff
add format_quality option in wireless 292/head
authorFelix Buehler <account@buehler.rocks>
Thu, 28 Jun 2018 20:16:37 +0000 (22:16 +0200)
committerFelix Buehler <account@buehler.rocks>
Fri, 29 Jun 2018 20:56:09 +0000 (22:56 +0200)
i3status.c
include/i3status.h
man/i3status.man
src/print_wireless_info.c

index 316159c26440c182aec3fd270f4d0e31d901eb65..76b63499ab4c3555d45f3469a8043ed6a015884c 100644 (file)
@@ -336,6 +336,7 @@ int main(int argc, char *argv[]) {
     cfg_opt_t wireless_opts[] = {
         CFG_STR("format_up", "W: (%quality at %essid, %bitrate) %ip", CFGF_NONE),
         CFG_STR("format_down", "W: down", CFGF_NONE),
     cfg_opt_t wireless_opts[] = {
         CFG_STR("format_up", "W: (%quality at %essid, %bitrate) %ip", CFGF_NONE),
         CFG_STR("format_down", "W: down", CFGF_NONE),
+        CFG_STR("format_quality", "%3d%s", CFGF_NONE),
         CFG_CUSTOM_ALIGN_OPT,
         CFG_CUSTOM_COLOR_OPTS,
         CFG_CUSTOM_MIN_WIDTH_OPT,
         CFG_CUSTOM_ALIGN_OPT,
         CFG_CUSTOM_COLOR_OPTS,
         CFG_CUSTOM_MIN_WIDTH_OPT,
@@ -693,7 +694,7 @@ int main(int argc, char *argv[]) {
                     interface = first_eth_interface(NET_TYPE_WIRELESS);
                 if (interface == NULL)
                     interface = title;
                     interface = first_eth_interface(NET_TYPE_WIRELESS);
                 if (interface == NULL)
                     interface = title;
-                print_wireless_info(json_gen, buffer, interface, cfg_getstr(sec, "format_up"), cfg_getstr(sec, "format_down"));
+                print_wireless_info(json_gen, buffer, interface, cfg_getstr(sec, "format_up"), cfg_getstr(sec, "format_down"), cfg_getstr(sec, "format_quality"));
                 SEC_CLOSE_MAP;
             }
 
                 SEC_CLOSE_MAP;
             }
 
index 7bedfeddc225924f4d6f1d6eee99cdffa6db5c1a..e25998783671ef31c94693b8c162f346f8d24f4e 100644 (file)
@@ -217,7 +217,7 @@ void print_battery_info(yajl_gen json_gen, char *buffer, int number, const char
 void print_time(yajl_gen json_gen, char *buffer, const char *title, const char *format, const char *tz, const char *locale, const char *format_time, time_t t);
 void print_ddate(yajl_gen json_gen, char *buffer, const char *format, time_t t);
 const char *get_ip_addr(const char *interface, int family);
 void print_time(yajl_gen json_gen, char *buffer, const char *title, const char *format, const char *tz, const char *locale, const char *format_time, time_t t);
 void print_ddate(yajl_gen json_gen, char *buffer, const char *format, time_t t);
 const char *get_ip_addr(const char *interface, int family);
-void print_wireless_info(yajl_gen json_gen, char *buffer, const char *interface, const char *format_up, const char *format_down);
+void print_wireless_info(yajl_gen json_gen, char *buffer, const char *interface, const char *format_up, const char *format_down, const char *quality_min_lenght);
 void print_run_watch(yajl_gen json_gen, char *buffer, const char *title, const char *pidfile, const char *format, const char *format_down);
 void print_path_exists(yajl_gen json_gen, char *buffer, const char *title, const char *path, const char *format, const char *format_down);
 void print_cpu_temperature_info(yajl_gen json_gen, char *buffer, int zone, const char *path, const char *format, const char *format_above_threshold, int);
 void print_run_watch(yajl_gen json_gen, char *buffer, const char *title, const char *pidfile, const char *format, const char *format_down);
 void print_path_exists(yajl_gen json_gen, char *buffer, const char *title, const char *path, const char *format, const char *format_down);
 void print_cpu_temperature_info(yajl_gen json_gen, char *buffer, int zone, const char *path, const char *format, const char *format_above_threshold, int);
index 31f25adfcd7c9003fb15d7151da52010c9648094..86f6216b4fa0f3d81506ae921e790f73d63f9252 100644 (file)
@@ -300,7 +300,8 @@ There also is an option "format_down". You can hide the output with
 
 Gets the link quality, frequency and ESSID of the given wireless network
 interface. You can specify different format strings for the network being
 
 Gets the link quality, frequency and ESSID of the given wireless network
 interface. You can specify different format strings for the network being
-connected or not connected.
+connected or not connected. The quality is padded with leading zeroes by
+default; to pad with something else use +format_quality+.
 
 The special interface name `_first_` will be replaced by the first wireless
 network interface found on the system (excluding devices starting with "lo").
 
 The special interface name `_first_` will be replaced by the first wireless
 network interface found on the system (excluding devices starting with "lo").
@@ -311,6 +312,8 @@ network interface found on the system (excluding devices starting with "lo").
 
 *Example format_down*: +W: down+
 
 
 *Example format_down*: +W: down+
 
+*Example format_quality*: +"%03d%s"+
+
 === Ethernet
 
 Gets the IP address and (if possible) the link speed of the given ethernet
 === Ethernet
 
 Gets the IP address and (if possible) the link speed of the given ethernet
index efdd59b777907953403d1418fe49d1ebcd59bc9b..dcfde528a0a846cc04a63235775f4724a5e0b2ed 100644 (file)
@@ -480,7 +480,7 @@ error1:
  * | 127.0.0.1    | no IP        | IPv4      | ok                |
  * | 127.0.0.1    | ::1/128      | IPv4      | ok                |
  */
  * | 127.0.0.1    | no IP        | IPv4      | ok                |
  * | 127.0.0.1    | ::1/128      | IPv4      | ok                |
  */
-void print_wireless_info(yajl_gen json_gen, char *buffer, const char *interface, const char *format_up, const char *format_down) {
+void print_wireless_info(yajl_gen json_gen, char *buffer, const char *interface, const char *format_up, const char *format_down, const char *format_quality) {
     const char *walk;
     char *outwalk = buffer;
     wireless_info_t info;
     const char *walk;
     char *outwalk = buffer;
     wireless_info_t info;
@@ -540,7 +540,7 @@ void print_wireless_info(yajl_gen json_gen, char *buffer, const char *interface,
         if (BEGINS_WITH(walk + 1, "quality")) {
             if (info.flags & WIRELESS_INFO_FLAG_HAS_QUALITY) {
                 if (info.quality_max)
         if (BEGINS_WITH(walk + 1, "quality")) {
             if (info.flags & WIRELESS_INFO_FLAG_HAS_QUALITY) {
                 if (info.quality_max)
-                    outwalk += sprintf(outwalk, "%3d%s", PERCENT_VALUE(info.quality, info.quality_max), pct_mark);
+                    outwalk += sprintf(outwalk, format_quality, PERCENT_VALUE(info.quality, info.quality_max), pct_mark);
                 else
                     outwalk += sprintf(outwalk, "%d", info.quality);
             } else {
                 else
                     outwalk += sprintf(outwalk, "%d", info.quality);
             } else {