From: Michael Stapelberg Date: Wed, 26 May 2010 21:40:05 +0000 (+0200) Subject: wsbar: print an error and exit after not being able to talk to i3 for 2 seconds ... X-Git-Tag: 4.0~73 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f6227bec6c60c83d53e8cae005ef1102b135136f;p=i3%2Fi3 wsbar: print an error and exit after not being able to talk to i3 for 2 seconds (Thanks badboy) --- diff --git a/i3-wsbar b/i3-wsbar index 2f62edb4..3c76864e 100755 --- a/i3-wsbar +++ b/i3-wsbar @@ -15,6 +15,13 @@ my $stdin; my $socket_path = undef; my ($workspaces, $outputs) = ([], {}); my $last_line = ""; +my $w = AnyEvent->timer( + after => 2, + cb => sub { + say "Connection to i3 timed out. Verify socket path ($socket_path)"; + exit 1; + } +); my $command = ""; my $input_on = ""; @@ -47,6 +54,16 @@ $| = 1; # Wait a short amount of time and try to connect to i3 again sub reconnect { my $timer; + if (!defined($w)) { + $w = AnyEvent->timer( + after => 2, + cb => sub { + say "Connection to i3 timed out. Verify socket path ($socket_path)"; + exit 1; + } + ); + } + my $c = sub { $timer = AnyEvent->timer( after => 0.01, @@ -65,6 +82,8 @@ sub connected { return; } + $w = undef; + $i3->subscribe({ workspace => \&ws_change, output => \&output_change,