.B color
If specified, color mode is on. This affects WLAN which will be displayed red if WLAN is down and the run_watch system which will display the status in red/green.
+.TP
+.B get_ethspeed
+Get current speed of the ethernet interface using the same mechanism as ethtool. You need to start wmiistatus with root privileges to use this.
+
.TP
.B normcolors
Specifies the colors for background/border in the same format (html colorcodes) as wmii's configuration, that is #222222 #333333 for example.
#include <glob.h>
#include <dirent.h>
#include <getopt.h>
+#include <linux/ethtool.h>
+#include <linux/sockios.h>
+
#define _IS_WMIISTATUS_C
#include "wmiistatus.h"
else (void)snprintf(part, sizeof(part), "W: down");
} else {
- char *ip_address;
+ const char *ip_address;
(void)snprintf(part, sizeof(part), "W: (%02d%%) ", quality);
ip_address = get_ip_address(wlan_interface);
strcpy(part+strlen(part), ip_address);
static char *get_eth_info() {
static char part[512];
const char *ip_address = get_ip_address(eth_interface);
+ int ethspeed = 0;
+
+ if (get_ethspeed) {
+ struct ifreq ifr;
+ struct ethtool_cmd ecmd;
+ int fd, err;
+
+ if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
+ write_error_to_statusbar("Could not open socket");
+
+ ecmd.cmd = ETHTOOL_GSET;
+ (void)memset(&ifr, 0, sizeof(ifr));
+ ifr.ifr_data = (caddr_t)&ecmd;
+ (void)strcpy(ifr.ifr_name, eth_interface);
+ if ((err = ioctl(fd, SIOCETHTOOL, &ifr)) == 0)
+ ethspeed = ecmd.speed;
+ else write_error_to_statusbar("Could not get interface speed. Insufficient privileges?");
+
+ (void)close(fd);
+ }
if (ip_address == NULL)
(void)snprintf(part, sizeof(part), "E: down");
- else (void)snprintf(part, sizeof(part), "E: %s", ip_address);
+ else {
+ if (get_ethspeed)
+ (void)snprintf(part, sizeof(part), "E: %s (%d Mbit/s)", ip_address, ethspeed);
+ else (void)snprintf(part, sizeof(part), "E: %s", ip_address);
+ }
return part;
}