diff options
author | Michael Stapelberg <michael@stapelberg.de> | 2014-12-07 15:14:02 +0100 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2014-12-07 15:17:31 +0100 |
commit | b219f47f394e536198997578e4cce3c539b84b6d (patch) | |
tree | 91e7a6b489ed3dbbfc70a07b0ffa86a03512a4a4 /i3status.c | |
parent | 7bdfb5b72e730f2131dccd75f211aaa6d2236954 (diff) |
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).
Diffstat (limited to 'i3status.c')
-rw-r--r-- | i3status.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -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; } |