Compare commits
4 Commits
02bb1399fb
...
0d2453623c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d2453623c | ||
|
|
139b014f7b | ||
|
|
7a270291b1 | ||
|
|
b287c84eed |
@@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
# TODO: on i3wm reload (i3status restart), restore active windows status
|
||||||
|
|
||||||
# we need to disable hash shuffling in order to make as less prints to stdout as possible
|
# we need to disable hash shuffling in order to make as less prints to stdout as possible
|
||||||
BEGIN {
|
BEGIN {
|
||||||
unless (defined $ENV{PERL_PERTURB_KEYS}) {
|
unless (defined $ENV{PERL_PERTURB_KEYS}) {
|
||||||
@@ -543,33 +545,7 @@ sub add_events () {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
# Try to tcp connect to server
|
# check openvpn state-file mtime
|
||||||
if ($CONF->{vpn}->{tcp_check}->{enabled}) {
|
|
||||||
push @EP, AnyEvent->timer (
|
|
||||||
after => 0, # first invoke ASAP
|
|
||||||
interval => 5, # then invoke every 5 seconds
|
|
||||||
cb => sub { # the callback to invoke
|
|
||||||
if (
|
|
||||||
my $sock = IO::Socket->new (
|
|
||||||
Domain => AF_INET,
|
|
||||||
proto => 'tcp',
|
|
||||||
PeerHost => $CONF->{vpn}->{tcp_check}->{host},
|
|
||||||
PeerPort => $CONF->{vpn}->{tcp_check}->{port},
|
|
||||||
Type => SOCK_STREAM,
|
|
||||||
Timeout => $CONF->{vpn}->{tcp_check}->{timeout}
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
$sock->shutdown (SHUT_WR);
|
|
||||||
$sock->close ();
|
|
||||||
$tcp_check = 1;
|
|
||||||
} else {
|
|
||||||
$tcp_check = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
# check file mtime
|
|
||||||
if ($CONF->{vpn}->{enabled}) {
|
if ($CONF->{vpn}->{enabled}) {
|
||||||
push @EP, AnyEvent->timer (
|
push @EP, AnyEvent->timer (
|
||||||
after => 0, # first invoke ASAP
|
after => 0, # first invoke ASAP
|
||||||
@@ -591,10 +567,36 @@ sub add_events () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# Try to tcp connect to server in vpn network
|
||||||
|
if ($CONF->{vpn}->{tcp_check}->{enabled}) {
|
||||||
|
push @EP, AnyEvent->timer (
|
||||||
|
after => 0, # first invoke ASAP
|
||||||
|
interval => 5, # then invoke every 5 seconds
|
||||||
|
cb => sub { # the callback to invoke
|
||||||
|
if (
|
||||||
|
my $sock = IO::Socket->new (
|
||||||
|
Domain => AF_INET,
|
||||||
|
proto => 'tcp',
|
||||||
|
PeerHost => $CONF->{vpn}->{tcp_check}->{host},
|
||||||
|
PeerPort => $CONF->{vpn}->{tcp_check}->{port},
|
||||||
|
Type => SOCK_STREAM,
|
||||||
|
Timeout => $CONF->{vpn}->{tcp_check}->{timeout}
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
$sock->shutdown (SHUT_WR);
|
||||||
|
$sock->close ();
|
||||||
|
$tcp_check = 1;
|
||||||
|
} else {
|
||||||
|
$tcp_check = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# poll pulseaudio volume on first sink in list
|
# poll pulseaudio volume on first sink in list
|
||||||
if ($CONF->{clock}->{enabled}) {
|
if ($CONF->{'simple-volume-pa'}) {
|
||||||
push @EP, AnyEvent->timer (
|
push @EP, AnyEvent->timer (
|
||||||
after => 0, # first invoke ASAP
|
after => 0, # first invoke ASAP
|
||||||
interval => 1, # then invoke every 1 second
|
interval => 1, # then invoke every 1 second
|
||||||
@@ -648,9 +650,8 @@ sub spawn (@) {
|
|||||||
} else {
|
} else {
|
||||||
exec $prg;
|
exec $prg;
|
||||||
}
|
}
|
||||||
} else { # Unable to fork()
|
|
||||||
print STDERR "[{\"full_text\":\"ERROR: Could not fork new process: $!\",\"color\":\"#ff0000\"}],\n";
|
|
||||||
}
|
}
|
||||||
|
# else - we just unable to fork, so silently ignore event
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -689,10 +690,16 @@ sub to_hours ($) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub readconf () {
|
sub readconf () {
|
||||||
my $file = "$ENV{HOME}/.i3/i3status-anyevent.json";
|
my $i3dir = "$ENV{HOME}/.config/i3";
|
||||||
|
|
||||||
|
unless (-d $i3dir) {
|
||||||
|
$i3dir = "$ENV{HOME}/.i3";
|
||||||
|
}
|
||||||
|
|
||||||
|
my $file = "$i3dir/i3status-anyevent.json";
|
||||||
|
|
||||||
unless (-f $file) {
|
unless (-f $file) {
|
||||||
$file = "$ENV{HOME}/.i3/config.json";
|
$file = "$i3dir/config.json";
|
||||||
}
|
}
|
||||||
|
|
||||||
my $FH;
|
my $FH;
|
||||||
|
|||||||
Reference in New Issue
Block a user