summaryrefslogtreecommitdiff
path: root/i3status.c
diff options
context:
space:
mode:
authorMichael Stapelberg <michael@stapelberg.de>2014-12-07 15:14:02 +0100
committerMichael Stapelberg <michael@stapelberg.de>2014-12-07 15:17:31 +0100
commitb219f47f394e536198997578e4cce3c539b84b6d (patch)
tree91e7a6b489ed3dbbfc70a07b0ffa86a03512a4a4 /i3status.c
parent7bdfb5b72e730f2131dccd75f211aaa6d2236954 (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.c14
1 files changed, 12 insertions, 2 deletions
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;
}