From b219f47f394e536198997578e4cce3c539b84b6d Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sun, 7 Dec 2014 15:14:02 +0100 Subject: support the special interface name _first_ for ethernet/wireless Since we have deterministic device names in Linux, these strings are a much better default in the i3status config than "eth0" and "wlan0" (what we used before). --- i3status.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'i3status.c') diff --git a/i3status.c b/i3status.c index fc16c49..daa2d00 100644 --- a/i3status.c +++ b/i3status.c @@ -576,13 +576,23 @@ int main(int argc, char *argv[]) { CASE_SEC_TITLE("wireless") { SEC_OPEN_MAP("wireless"); - print_wireless_info(json_gen, buffer, title, cfg_getstr(sec, "format_up"), cfg_getstr(sec, "format_down")); + const char *interface = NULL; + if (strcasecmp(title, "_first_") == 0) + interface = first_eth_interface(NET_TYPE_WIRELESS); + if (interface == NULL) + interface = title; + print_wireless_info(json_gen, buffer, interface, cfg_getstr(sec, "format_up"), cfg_getstr(sec, "format_down")); SEC_CLOSE_MAP; } CASE_SEC_TITLE("ethernet") { SEC_OPEN_MAP("ethernet"); - print_eth_info(json_gen, buffer, title, cfg_getstr(sec, "format_up"), cfg_getstr(sec, "format_down")); + const char *interface = NULL; + if (strcasecmp(title, "_first_") == 0) + interface = first_eth_interface(NET_TYPE_ETHERNET); + if (interface == NULL) + interface = title; + print_eth_info(json_gen, buffer, interface, cfg_getstr(sec, "format_up"), cfg_getstr(sec, "format_down")); SEC_CLOSE_MAP; } -- cgit v1.2.3