1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-16 10:05:22 +00:00

When using without argument, make sure that it shows the essid of the first device that has one instead of using the default network device (because most of the times this will be a non-wireless device)

This commit is contained in:
Nikolas Garofil 2010-02-21 15:12:38 +01:00
parent d91214e290
commit d184efb418
2 changed files with 9 additions and 2 deletions

View File

@ -241,7 +241,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long
#ifdef BUILD_WLAN #ifdef BUILD_WLAN
END OBJ(wireless_essid, &update_net_stats) END OBJ(wireless_essid, &update_net_stats)
parse_net_stat_arg(obj, arg, free_at_crash); obj->data.opaque = get_net_stat(arg, obj, free_at_crash);
obj->callbacks.print = &print_wireless_essid; obj->callbacks.print = &print_wireless_essid;
END OBJ(wireless_mode, &update_net_stats) END OBJ(wireless_mode, &update_net_stats)
parse_net_stat_arg(obj, arg, free_at_crash); parse_net_stat_arg(obj, arg, free_at_crash);

View File

@ -226,8 +226,15 @@ void print_wireless_essid(struct text_object *obj, char *p, int p_max_size)
{ {
struct net_stat *ns = (struct net_stat *)obj->data.opaque; struct net_stat *ns = (struct net_stat *)obj->data.opaque;
if (!ns) if (!ns) {
for(unsigned int i = 0; *(netstats[i].dev) != 0; i++) {
if(*(netstats[i].essid) != 0) {
snprintf(p, p_max_size, "%s", netstats[i].essid);
return;
}
}
return; return;
}
snprintf(p, p_max_size, "%s", ns->essid); snprintf(p, p_max_size, "%s", ns->essid);
} }