diff options
author | Michael Stapelberg <michael@stapelberg.de> | 2010-09-22 19:59:48 +0200 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2010-09-22 19:59:48 +0200 |
commit | af5fd7b77ea00d6c1390e70310d51828016ab2b0 (patch) | |
tree | 358bd9f22570ebc8db4a920cabd464d6fa1c1cfa | |
parent | fac05bf4e8368ddf8fa43f97d199c7a486441d1d (diff) |
Implement displaying the wireless connection speed (Thanks Felicitus)
Based on a patch by Felicitus.
-rw-r--r-- | i3status.c | 2 | ||||
-rw-r--r-- | man/i3status.man | 4 | ||||
-rw-r--r-- | src/print_wireless_info.c | 14 |
3 files changed, 17 insertions, 3 deletions
@@ -103,7 +103,7 @@ int main(int argc, char *argv[]) { }; cfg_opt_t wireless_opts[] = { - CFG_STR("format_up", "W: (%quality at %essid) %ip", CFGF_NONE), + CFG_STR("format_up", "W: (%quality at %essid, %bitrate) %ip", CFGF_NONE), CFG_STR("format_down", "W: down", CFGF_NONE), CFG_END() }; diff --git a/man/i3status.man b/man/i3status.man index 0274cca..a93f90d 100644 --- a/man/i3status.man +++ b/man/i3status.man @@ -57,7 +57,7 @@ order += "load" order += "time" wireless wlan0 { - format_up = "W: (%quality at %essid) %ip" + format_up = "W: (%quality at %essid, %bitrate) %ip" format_down = "W: down" } @@ -160,7 +160,7 @@ connected. *Example order*: +wireless wlan0+ -*Example format*: +W: (%quality at %essid) %ip+ +*Example format*: +W: (%quality at %essid, %bitrate) %ip+ === Ethernet diff --git a/src/print_wireless_info.c b/src/print_wireless_info.c index 60eb906..3a96b86 100644 --- a/src/print_wireless_info.c +++ b/src/print_wireless_info.c @@ -25,6 +25,7 @@ typedef struct { int signal_level_max; int noise_level; int noise_level_max; + int bitrate; } wireless_info_t; static int get_wireless_info(const char *interface, wireless_info_t *info) { @@ -132,6 +133,10 @@ static int get_wireless_info(const char *interface, wireless_info_t *info) { } } + struct iwreq wrq; + if (iw_get_ext(skfd, interface, SIOCGIWRATE, &wrq) >= 0) + info->bitrate = wrq.u.bitrate.value; + close(skfd); return 1; #endif @@ -210,6 +215,15 @@ void print_wireless_info(const char *interface, const char *format_up, const cha else (void)printf("no IP"); walk += strlen("ip"); } + + if (BEGINS_WITH(walk+1, "bitrate")) { + char buffer[128]; + + iw_print_bitrate(buffer, sizeof(buffer), info.bitrate); + + printf("%s", buffer); + walk += strlen("bitrate"); + } } (void)printf("%s", endcolor()); |