};
cfg_opt_t ethernet_opts[] = {
- CFG_STR("format", "E: %ip (%speed)", CFGF_NONE),
+ CFG_STR("format_up", "E: %ip (%speed)", CFGF_NONE),
+ CFG_STR("format_down", "E: down", CFGF_NONE),
CFG_END()
};
print_wireless_info(title, cfg_getstr(sec, "format_up"), cfg_getstr(sec, "format_down"));
CASE_SEC_TITLE("ethernet")
- print_eth_info(title, cfg_getstr(sec, "format"));
+ print_eth_info(title, cfg_getstr(sec, "format_up"), cfg_getstr(sec, "format_down"));
CASE_SEC_TITLE("battery")
print_battery_info(atoi(title), cfg_getstr(sec, "format"));
ethernet eth0 {
# if you use %speed, i3status requires root privileges
- format = "E: %ip (%speed)"
+ format_up = "E: %ip (%speed)"
+ format_down = "E: down"
}
battery 0 {
void print_wireless_info(const char *interface, const char *format_up, const char *format_down);
void print_run_watch(const char *title, const char *pidfile, const char *format);
void print_cpu_temperature_info(int zone, const char *format);
-void print_eth_info(const char *interface, const char *format);
+void print_eth_info(const char *interface, const char *format_up, const char *format_down);
void print_load();
bool process_runs(const char *path);
* Combines ethernet IP addresses and speed (if requested) for displaying
*
*/
-void print_eth_info(const char *interface, const char *format) {
+void print_eth_info(const char *interface, const char *format_up, const char *format_down) {
const char *walk;
const char *ip_address = get_ip_addr(interface);
- for (walk = format; *walk != '\0'; walk++) {
+ if (ip_address == NULL) {
+ printf("%s", format_down);
+ return;
+ }
+
+ for (walk = format_up; *walk != '\0'; walk++) {
if (*walk != '%') {
putchar(*walk);
continue;