i3status-anyevent: Make tcp connect check only if vpn state check enabled
This commit is contained in:
@@ -545,7 +545,30 @@ sub add_events () {
|
||||
},
|
||||
);
|
||||
|
||||
# Try to tcp connect to server
|
||||
# check openvpn state-file mtime
|
||||
if ($CONF->{vpn}->{enabled}) {
|
||||
push @EP, AnyEvent->timer (
|
||||
after => 0, # first invoke ASAP
|
||||
interval => 3, # then invoke every 3 seconds
|
||||
cb => sub { # the callback to invoke
|
||||
my $mtime = (stat $CONF->{vpn}->{statusfile}) [8];
|
||||
|
||||
if (defined $mtime) {
|
||||
if (($mtime - $file_check_mtime) < $CONF->{vpn}->{mtime_threshold}) {
|
||||
$file_check = 1;
|
||||
} else {
|
||||
$file_check = 0;
|
||||
}
|
||||
|
||||
$file_check_mtime = $mtime;
|
||||
} else {
|
||||
$mtime = 0;
|
||||
$file_check = 0;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
# Try to tcp connect to server in vpn network
|
||||
if ($CONF->{vpn}->{tcp_check}->{enabled}) {
|
||||
push @EP, AnyEvent->timer (
|
||||
after => 0, # first invoke ASAP
|
||||
@@ -570,29 +593,6 @@ sub add_events () {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
# check file mtime
|
||||
if ($CONF->{vpn}->{enabled}) {
|
||||
push @EP, AnyEvent->timer (
|
||||
after => 0, # first invoke ASAP
|
||||
interval => 3, # then invoke every 3 seconds
|
||||
cb => sub { # the callback to invoke
|
||||
my $mtime = (stat $CONF->{vpn}->{statusfile}) [8];
|
||||
|
||||
if (defined $mtime) {
|
||||
if (($mtime - $file_check_mtime) < $CONF->{vpn}->{mtime_threshold}) {
|
||||
$file_check = 1;
|
||||
} else {
|
||||
$file_check = 0;
|
||||
}
|
||||
|
||||
$file_check_mtime = $mtime;
|
||||
} else {
|
||||
$mtime = 0;
|
||||
$file_check = 0;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
# poll pulseaudio volume on first sink in list
|
||||
|
||||
Reference in New Issue
Block a user