From afa90535f82de1920e6034334b79ebeb7bad9d2f Mon Sep 17 00:00:00 2001 From: jasper Date: Mon, 8 Oct 2012 14:45:10 +0000 Subject: [PATCH] - implement the ethernet media description (%speed flag) --- x11/i3status/Makefile | 4 +- .../patches/patch-src_print_eth_info_c | 57 +++++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 x11/i3status/patches/patch-src_print_eth_info_c diff --git a/x11/i3status/Makefile b/x11/i3status/Makefile index 9c8276a789d..4f9d7e76fae 100644 --- a/x11/i3status/Makefile +++ b/x11/i3status/Makefile @@ -1,11 +1,11 @@ -# $OpenBSD: Makefile,v 1.15 2012/10/08 11:49:30 jasper Exp $ +# $OpenBSD: Makefile,v 1.16 2012/10/08 14:45:10 jasper Exp $ ONLY_FOR_ARCHS= ${APM_ARCHS} COMMENT= generate a statusbar for use with i3/xmobar/dzen2 DISTNAME= i3status-2.6 -REVISION= 6 +REVISION= 7 CATEGORIES= x11 sysutils HOMEPAGE= http://i3wm.org/i3status/ diff --git a/x11/i3status/patches/patch-src_print_eth_info_c b/x11/i3status/patches/patch-src_print_eth_info_c new file mode 100644 index 00000000000..d3b6eb775e0 --- /dev/null +++ b/x11/i3status/patches/patch-src_print_eth_info_c @@ -0,0 +1,57 @@ +$OpenBSD: patch-src_print_eth_info_c,v 1.1 2012/10/08 14:45:10 jasper Exp $ + +Implement the %speed option for ethernet blocks. + +--- src/print_eth_info.c.orig Mon Oct 8 18:39:07 2012 ++++ src/print_eth_info.c Mon Oct 8 18:39:23 2012 +@@ -25,7 +25,11 @@ + (IFM_TYPE((dt)) == 0 || IFM_TYPE((dt)) == IFM_TYPE((t))) + + #define PART_ETHSPEED "E: %s (%s)" ++#endif + ++#if defined(__OpenBSD__) ++#include ++#include + #endif + + static int print_eth_speed(char *outwalk, const char *interface) { +@@ -65,6 +69,38 @@ static int print_eth_speed(char *outwalk, const char * + } + ethspeed = (desc->ifmt_string != NULL ? desc->ifmt_string : "?"); + return sprintf(outwalk, "%s", ethspeed); ++#elif defined(__OpenBSD__) ++ char *ethspeed; ++ struct ifmediareq ifmr; ++ ++ (void) memset(&ifmr, 0, sizeof(ifmr)); ++ (void) strlcpy(ifmr.ifm_name, interface, sizeof(ifmr.ifm_name)); ++ ++ if (ioctl(general_socket, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) { ++ if (errno != E2BIG) ++ return sprintf(outwalk, "?"); ++ } ++ ++ struct ifmedia_description *desc; ++ struct ifmedia_description ifm_subtype_descriptions[] = ++ IFM_SUBTYPE_DESCRIPTIONS; ++ ++ for (desc = ifm_subtype_descriptions; desc->ifmt_string != NULL; desc++) { ++ /* ++ * Skip these non-informative values and go right ahead to the ++ * actual speeds. ++ */ ++ if (strncmp(desc->ifmt_string, "autoselect", strlen("autoselect")) == 0 || ++ strncmp(desc->ifmt_string, "auto", strlen("auto")) == 0) ++ continue; ++ ++ if (IFM_TYPE_MATCH(desc->ifmt_word, ifmr.ifm_active) && ++ IFM_SUBTYPE(desc->ifmt_word) == IFM_SUBTYPE(ifmr.ifm_active)) ++ break; ++ } ++ ethspeed = (desc->ifmt_string != NULL ? desc->ifmt_string : "?"); ++ return sprintf(outwalk, "%s", ethspeed); ++ + #else + return sprintf(outwalk, "?"); + #endif