diff --git a/src/conky.cc b/src/conky.cc index b088ed43..b924c854 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -183,7 +183,6 @@ double update_interval_bat; void *global_cpu = NULL; static conky::range_config_setting max_text_width("max_text_width", 0, std::numeric_limits::max(), 0, true); -int ifup_strictness = IFUP_UP; #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) extern kvm_t *kd; @@ -3023,22 +3022,6 @@ char load_config_file(const char *f) } } #endif - CONF("if_up_strictness") { - if (!value) { - NORM_ERR("incorrect if_up_strictness value, defaulting to 'up'"); - ifup_strictness = IFUP_UP; - } else if (strcasecmp(value, "up") == EQUAL) { - ifup_strictness = IFUP_UP; - } else if (strcasecmp(value, "link") == EQUAL) { - ifup_strictness = IFUP_LINK; - } else if (strcasecmp(value, "address") == EQUAL) { - ifup_strictness = IFUP_ADDR; - } else { - NORM_ERR("incorrect if_up_strictness value, defaulting to 'up'"); - ifup_strictness = IFUP_UP; - } - } - CONF("temperature_unit") { if (!value) { NORM_ERR("config option 'temperature_unit' needs an argument, either 'celsius' or 'fahrenheit'"); diff --git a/src/conky.h b/src/conky.h index 5294aa55..87d31171 100644 --- a/src/conky.h +++ b/src/conky.h @@ -275,15 +275,6 @@ extern struct information info; /* defined in conky.c */ extern double current_update_time, last_update_time, update_interval; -/* if_up strictness selector - * needed by conky.c and linux.c (and potentially others) */ -enum _ifup_strictness { - IFUP_UP, - IFUP_LINK, - IFUP_ADDR -}; -extern int ifup_strictness; - extern conky::range_config_setting stippled_borders; void set_current_text_color(long colour); diff --git a/src/net_stat.cc b/src/net_stat.cc index aceae345..d95ab96f 100644 --- a/src/net_stat.cc +++ b/src/net_stat.cc @@ -43,6 +43,22 @@ /* network interface stuff */ +enum if_up_strictness_ { + IFUP_UP, + IFUP_LINK, + IFUP_ADDR +}; + +template<> +conky::lua_traits::Map conky::lua_traits::map = { + { "up", IFUP_UP }, + { "link", IFUP_LINK }, + { "address", IFUP_ADDR } +}; + +static conky::simple_config_setting if_up_strictness("if_up_strictness", + IFUP_UP, true); + struct net_stat netstats[MAX_NET_INTERFACES]; struct net_stat *get_net_stat(const char *dev, void *free_at_crash1, void *free_at_crash2) @@ -378,12 +394,12 @@ int interface_up(struct text_object *obj) if (!(ifr.ifr_flags & IFF_UP)) /* iface is not up */ goto END_FALSE; - if (ifup_strictness == IFUP_UP) + if (if_up_strictness.get(*state) == IFUP_UP) goto END_TRUE; if (!(ifr.ifr_flags & IFF_RUNNING)) goto END_FALSE; - if (ifup_strictness == IFUP_LINK) + if (if_up_strictness.get(*state) == IFUP_LINK) goto END_TRUE; if (ioctl(fd, SIOCGIFADDR, &ifr)) {