mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-17 18:45:10 +00:00
Make if_up_strictness a lua setting
This commit is contained in:
parent
127ed29fb9
commit
0085402d08
17
src/conky.cc
17
src/conky.cc
@ -183,7 +183,6 @@ double update_interval_bat;
|
|||||||
void *global_cpu = NULL;
|
void *global_cpu = NULL;
|
||||||
static conky::range_config_setting<unsigned int> max_text_width("max_text_width", 0,
|
static conky::range_config_setting<unsigned int> max_text_width("max_text_width", 0,
|
||||||
std::numeric_limits<unsigned int>::max(), 0, true);
|
std::numeric_limits<unsigned int>::max(), 0, true);
|
||||||
int ifup_strictness = IFUP_UP;
|
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||||
extern kvm_t *kd;
|
extern kvm_t *kd;
|
||||||
@ -3023,22 +3022,6 @@ char load_config_file(const char *f)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#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") {
|
CONF("temperature_unit") {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
NORM_ERR("config option 'temperature_unit' needs an argument, either 'celsius' or 'fahrenheit'");
|
NORM_ERR("config option 'temperature_unit' needs an argument, either 'celsius' or 'fahrenheit'");
|
||||||
|
@ -275,15 +275,6 @@ extern struct information info;
|
|||||||
/* defined in conky.c */
|
/* defined in conky.c */
|
||||||
extern double current_update_time, last_update_time, update_interval;
|
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<char> stippled_borders;
|
extern conky::range_config_setting<char> stippled_borders;
|
||||||
|
|
||||||
void set_current_text_color(long colour);
|
void set_current_text_color(long colour);
|
||||||
|
@ -43,6 +43,22 @@
|
|||||||
|
|
||||||
/* network interface stuff */
|
/* network interface stuff */
|
||||||
|
|
||||||
|
enum if_up_strictness_ {
|
||||||
|
IFUP_UP,
|
||||||
|
IFUP_LINK,
|
||||||
|
IFUP_ADDR
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
conky::lua_traits<if_up_strictness_>::Map conky::lua_traits<if_up_strictness_>::map = {
|
||||||
|
{ "up", IFUP_UP },
|
||||||
|
{ "link", IFUP_LINK },
|
||||||
|
{ "address", IFUP_ADDR }
|
||||||
|
};
|
||||||
|
|
||||||
|
static conky::simple_config_setting<if_up_strictness_> if_up_strictness("if_up_strictness",
|
||||||
|
IFUP_UP, true);
|
||||||
|
|
||||||
struct net_stat netstats[MAX_NET_INTERFACES];
|
struct net_stat netstats[MAX_NET_INTERFACES];
|
||||||
|
|
||||||
struct net_stat *get_net_stat(const char *dev, void *free_at_crash1, void *free_at_crash2)
|
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 */
|
if (!(ifr.ifr_flags & IFF_UP)) /* iface is not up */
|
||||||
goto END_FALSE;
|
goto END_FALSE;
|
||||||
if (ifup_strictness == IFUP_UP)
|
if (if_up_strictness.get(*state) == IFUP_UP)
|
||||||
goto END_TRUE;
|
goto END_TRUE;
|
||||||
|
|
||||||
if (!(ifr.ifr_flags & IFF_RUNNING))
|
if (!(ifr.ifr_flags & IFF_RUNNING))
|
||||||
goto END_FALSE;
|
goto END_FALSE;
|
||||||
if (ifup_strictness == IFUP_LINK)
|
if (if_up_strictness.get(*state) == IFUP_LINK)
|
||||||
goto END_TRUE;
|
goto END_TRUE;
|
||||||
|
|
||||||
if (ioctl(fd, SIOCGIFADDR, &ifr)) {
|
if (ioctl(fd, SIOCGIFADDR, &ifr)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user