mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-26 08:38:26 +00:00
Changed addr to print "No Address" when there is no address
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1167 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
bb80900ca6
commit
9ffbf32b1d
@ -5,7 +5,7 @@
|
||||
<option>interface</option>
|
||||
</term>
|
||||
<listitem>
|
||||
IP address for an interface
|
||||
IP address for an interface, or "No Address" if no address is assigned.
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
17
src/conky.c
17
src/conky.c
@ -4718,11 +4718,18 @@ static void generate_text_internal(char *p, int p_max_size,
|
||||
}
|
||||
#ifdef HAVE_POPEN
|
||||
OBJ(addr) {
|
||||
snprintf(p, p_max_size, "%u.%u.%u.%u",
|
||||
obj->data.net->addr.sa_data[2] & 255,
|
||||
obj->data.net->addr.sa_data[3] & 255,
|
||||
obj->data.net->addr.sa_data[4] & 255,
|
||||
obj->data.net->addr.sa_data[5] & 255);
|
||||
if ((obj->data.net->addr.sa_data[2] & 255) == 0
|
||||
&& (obj->data.net->addr.sa_data[3] & 255) == 0
|
||||
&& (obj->data.net->addr.sa_data[4] & 255) == 0
|
||||
&& (obj->data.net->addr.sa_data[5] & 255) == 0) {
|
||||
snprintf(p, p_max_size, "No Address");
|
||||
} else {
|
||||
snprintf(p, p_max_size, "%u.%u.%u.%u",
|
||||
obj->data.net->addr.sa_data[2] & 255,
|
||||
obj->data.net->addr.sa_data[3] & 255,
|
||||
obj->data.net->addr.sa_data[4] & 255,
|
||||
obj->data.net->addr.sa_data[5] & 255);
|
||||
}
|
||||
}
|
||||
#if defined(__linux__)
|
||||
OBJ(addrs) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user