1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-27 20:44:56 +00:00

Add support for $wireless_channel (based on a patch by Timothy Ball)

This commit is contained in:
Nikolas Garofil 2010-06-07 09:54:25 +02:00
parent b5800a3418
commit 6ccde5e7e7
4 changed files with 26 additions and 0 deletions

View File

@ -360,6 +360,9 @@ struct text_object *construct_text_object(char *s, const char *arg, long
END OBJ(wireless_essid, &update_net_stats) END OBJ(wireless_essid, &update_net_stats)
obj->data.opaque = get_net_stat(arg, obj, 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_channel, &update_net_stats)
parse_net_stat_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_wireless_channel;
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);
obj->callbacks.print = &print_wireless_mode; obj->callbacks.print = &print_wireless_mode;

View File

@ -546,6 +546,14 @@ int update_net_stats(void)
snprintf(ns->essid, 32, "off/any"); snprintf(ns->essid, 32, "off/any");
} }
} }
// get channel
if (winfo->b.has_freq) {
if(winfo->has_range == 1) {
ns->channel = iw_freq_to_channel(winfo->b.freq, &(winfo->range));
} else {
ns->channel = 0;
}
}
snprintf(ns->mode, 16, "%s", iw_operation_mode[winfo->b.mode]); snprintf(ns->mode, 16, "%s", iw_operation_mode[winfo->b.mode]);
} }

View File

@ -247,6 +247,19 @@ void print_wireless_mode(struct text_object *obj, char *p, int p_max_size)
snprintf(p, p_max_size, "%s", ns->mode); snprintf(p, p_max_size, "%s", ns->mode);
} }
void print_wireless_channel(struct text_object *obj, char *p, int p_max_size)
{
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
if (!ns)
return;
if(ns->channel != 0) {
snprintf(p, p_max_size, "%i", ns->channel);
} else {
snprintf(p, p_max_size, "/");
}
}
void print_wireless_bitrate(struct text_object *obj, char *p, int p_max_size) void print_wireless_bitrate(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;

View File

@ -46,6 +46,7 @@ struct net_stat {
double net_rec[15], net_trans[15]; double net_rec[15], net_trans[15];
// wireless extensions // wireless extensions
char essid[32]; char essid[32];
int channel;
char bitrate[16]; char bitrate[16];
char mode[16]; char mode[16];
int link_qual; int link_qual;
@ -76,6 +77,7 @@ double upspeedgraphval(struct text_object *);
#endif /* BUILD_X11 */ #endif /* BUILD_X11 */
#ifdef BUILD_WLAN #ifdef BUILD_WLAN
void print_wireless_essid(struct text_object *, char *, int); void print_wireless_essid(struct text_object *, char *, int);
void print_wireless_channel(struct text_object *, char *, int);
void print_wireless_mode(struct text_object *, char *, int); void print_wireless_mode(struct text_object *, char *, int);
void print_wireless_bitrate(struct text_object *, char *, int); void print_wireless_bitrate(struct text_object *, char *, int);
void print_wireless_ap(struct text_object *, char *, int); void print_wireless_ap(struct text_object *, char *, int);