Make device argument optional for most net stats.
authorBrenden Matthews <brenden@rty.ca>
Sun, 7 Jun 2009 04:56:29 +0000 (22:56 -0600)
committerBrenden Matthews <brenden@rty.ca>
Sun, 7 Jun 2009 04:56:29 +0000 (22:56 -0600)
We can use DEFAULTNETDEV for more than just up/downspeedgraph.

doc/variables.xml
src/conky.c

index a15b8c4..d82f329 100644 (file)
@@ -31,7 +31,7 @@
             <command>
                 <option>addr</option>
             </command>
-            <option>interface</option>
+            <option>(interface)</option>
         </term>
         <listitem>IP address for an interface, or "No Address" if
         no address is assigned.
@@ -42,7 +42,7 @@
             <command>
                 <option>addrs</option>
             </command>
-            <option>interface</option>
+            <option>(interface)</option>
         </term>
         <listitem>IP addresses for an interface (if one - works
         like addr). Linux only.
             <command>
                 <option>downspeed</option>
             </command>
-            <option>net</option>
+            <option>(net)</option>
         </term>
         <listitem>Download speed in KiB
         <para /></listitem>
             <command>
                 <option>downspeedf</option>
             </command>
-            <option>net</option>
+            <option>(net)</option>
         </term>
         <listitem>Download speed in KiB with one decimal
         <para /></listitem>
             <command>
                 <option>totaldown</option>
             </command>
-            <option>net</option>
+            <option>(net)</option>
         </term>
         <listitem>Total download, overflows at 4 GB on Linux with
         32-bit arch and there doesn't seem to be a way to know how
             <command>
                 <option>totalup</option>
             </command>
-            <option>net</option>
+            <option>(net)</option>
         </term>
         <listitem>Total upload, this one too, may overflow
         <para /></listitem>
             <command>
                 <option>upspeed</option>
             </command>
-            <option>net</option>
+            <option>(net)</option>
         </term>
         <listitem>Upload speed in KiB
         <para /></listitem>
             <command>
                 <option>upspeedf</option>
             </command>
-            <option>net</option>
+            <option>(net)</option>
         </term>
         <listitem>Upload speed in KiB with one decimal
         <para /></listitem>
             <command>
                 <option>wireless_ap</option>
             </command>
-            <option>net</option>
+            <option>(net)</option>
         </term>
         <listitem>Wireless access point MAC address (Linux only)
         <para /></listitem>
             <command>
                 <option>wireless_bitrate</option>
             </command>
-            <option>net</option>
+            <option>(net)</option>
         </term>
         <listitem>Wireless bitrate (ie 11 Mb/s) (Linux only)
         <para /></listitem>
             <command>
                 <option>wireless_essid</option>
             </command>
-            <option>net</option>
+            <option>(net)</option>
         </term>
         <listitem>Wireless access point ESSID (Linux only)
         <para /></listitem>
             <command>
                 <option>wireless_link_bar</option>
             </command>
-            <option>(height), (width) net</option>
+            <option>(height),(width) (net)</option>
         </term>
         <listitem>Wireless link quality bar (Linux only)
         <para /></listitem>
             <command>
                 <option>wireless_link_qual</option>
             </command>
-            <option>net</option>
+            <option>(net)</option>
         </term>
         <listitem>Wireless link quality (Linux only)
         <para /></listitem>
             <command>
                 <option>wireless_link_qual_max</option>
             </command>
-            <option>net</option>
+            <option>(net)</option>
         </term>
         <listitem>Wireless link quality maximum value (Linux only)
         <para /></listitem>
             <command>
                 <option>wireless_link_qual_perc</option>
             </command>
-            <option>net</option>
+            <option>(net)</option>
         </term>
         <listitem>Wireless link quality in percents (Linux only)
         <para /></listitem>
             <command>
                 <option>wireless_mode</option>
             </command>
-            <option>net</option>
+            <option>(net)</option>
         </term>
         <listitem>Wireless mode (Managed/Ad-Hoc/Master) (Linux
         only)
index 6ba467d..1792277 100644 (file)
@@ -1267,43 +1267,64 @@ static struct text_object *construct_text_object(const char *s,
                if (arg) {
                        obj->data.net = get_net_stat(arg);
                } else {
-                       CRIT_ERR("wireless_essid: needs an argument");
+                       // default to DEFAULTNETDEV
+                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
+                       obj->data.net = get_net_stat(buf);
+                       free(buf);
                }
        END OBJ(wireless_mode, INFO_NET)
                if (arg) {
                        obj->data.net = get_net_stat(arg);
                } else {
-                       CRIT_ERR("wireless_mode: needs an argument");
+                       // default to DEFAULTNETDEV
+                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
+                       obj->data.net = get_net_stat(buf);
+                       free(buf);
                }
        END OBJ(wireless_bitrate, INFO_NET)
                if (arg) {
                        obj->data.net = get_net_stat(arg);
                } else {
-                       CRIT_ERR("wireless_bitrate: needs an argument");
+                       // default to DEFAULTNETDEV
+                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
+                       obj->data.net = get_net_stat(buf);
+                       free(buf);
                }
        END OBJ(wireless_ap, INFO_NET)
                if (arg) {
                        obj->data.net = get_net_stat(arg);
                } else {
-                       CRIT_ERR("wireless_ap: needs an argument");
+                       // default to DEFAULTNETDEV
+                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
+                       obj->data.net = get_net_stat(buf);
+                       free(buf);
                }
        END OBJ(wireless_link_qual, INFO_NET)
                if (arg) {
                        obj->data.net = get_net_stat(arg);
                } else {
-                       CRIT_ERR("wireless_link_qual: needs an argument");
+                       // default to DEFAULTNETDEV
+                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
+                       obj->data.net = get_net_stat(buf);
+                       free(buf);
                }
        END OBJ(wireless_link_qual_max, INFO_NET)
                if (arg) {
                        obj->data.net = get_net_stat(arg);
                } else {
-                       CRIT_ERR("wireless_link_qual_max: needs an argument");
+                       // default to DEFAULTNETDEV
+                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
+                       obj->data.net = get_net_stat(buf);
+                       free(buf);
                }
        END OBJ(wireless_link_qual_perc, INFO_NET)
                if (arg) {
                        obj->data.net = get_net_stat(arg);
                } else {
-                       CRIT_ERR("wireless_link_qual_perc: needs an argument");
+                       // default to DEFAULTNETDEV
+                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
+                       obj->data.net = get_net_stat(buf);
+                       free(buf);
                }
        END OBJ(wireless_link_bar, INFO_NET)
                SIZE_DEFAULTS(bar);
@@ -1311,7 +1332,10 @@ static struct text_object *construct_text_object(const char *s,
                        arg = scan_bar(arg, &obj->a, &obj->b);
                        obj->data.net = get_net_stat(arg);
                } else {
-                       CRIT_ERR("wireless_link_bar: needs an argument");
+                       // default to DEFAULTNETDEV
+                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
+                       obj->data.net = get_net_stat(buf);
+                       free(buf);
                }
 #endif /* HAVE_IWLIB */
 
@@ -1586,13 +1610,19 @@ static struct text_object *construct_text_object(const char *s,
                if (arg) {
                        obj->data.net = get_net_stat(arg);
                } else {
-                       CRIT_ERR("downspeed needs argument");
+                       // default to DEFAULTNETDEV
+                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
+                       obj->data.net = get_net_stat(buf);
+                       free(buf);
                }
        END OBJ(downspeedf, INFO_NET)
                if (arg) {
                        obj->data.net = get_net_stat(arg);
                } else {
-                       CRIT_ERR("downspeedf needs argument");
+                       // default to DEFAULTNETDEV
+                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
+                       obj->data.net = get_net_stat(buf);
+                       free(buf);
                }
 #ifdef X11
        END OBJ(downspeedgraph, INFO_NET)
@@ -1927,14 +1957,20 @@ static struct text_object *construct_text_object(const char *s,
                if (arg) {
                        obj->data.net = get_net_stat(arg);
                } else {
-                       CRIT_ERR("addr needs argument");
+                       // default to DEFAULTNETDEV
+                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
+                       obj->data.net = get_net_stat(buf);
+                       free(buf);
                }
 #if defined(__linux__)
        END OBJ(addrs, INFO_NET)
                if (arg) {
                        obj->data.net = get_net_stat(arg);
                } else {
-                       CRIT_ERR("addrs needs argument");
+                       // default to DEFAULTNETDEV
+                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
+                       obj->data.net = get_net_stat(buf);
+                       free(buf);
                }
 #endif /* __linux__ */
        END OBJ(tail, 0)
@@ -2387,14 +2423,20 @@ static struct text_object *construct_text_object(const char *s,
                if (arg) {
                        obj->data.net = get_net_stat(arg);
                } else {
-                       CRIT_ERR("totaldown needs argument");
+                       // default to DEFAULTNETDEV
+                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
+                       obj->data.net = get_net_stat(buf);
+                       free(buf);
                }
        END OBJ(totalup, INFO_NET)
                obj->data.net = get_net_stat(arg);
                if (arg) {
                        obj->data.net = get_net_stat(arg);
                } else {
-                       CRIT_ERR("totalup needs argument");
+                       // default to DEFAULTNETDEV
+                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
+                       obj->data.net = get_net_stat(buf);
+                       free(buf);
                }
        END OBJ(updates, 0)
        END OBJ_IF(if_updatenr, 0)
@@ -2409,13 +2451,19 @@ static struct text_object *construct_text_object(const char *s,
                if (arg) {
                        obj->data.net = get_net_stat(arg);
                } else {
-                       CRIT_ERR("upspeed needs argument");
+                       // default to DEFAULTNETDEV
+                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
+                       obj->data.net = get_net_stat(buf);
+                       free(buf);
                }
        END OBJ(upspeedf, INFO_NET)
                if (arg) {
                        obj->data.net = get_net_stat(arg);
                } else {
-                       CRIT_ERR("upspeedf needs argument");
+                       // default to DEFAULTNETDEV
+                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
+                       obj->data.net = get_net_stat(buf);
+                       free(buf);
                }
 
 #ifdef X11