Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
wsbar: print an error and exit after not being able to talk to i3 for…
Browse files Browse the repository at this point in the history
… 2 seconds (Thanks badboy)
  • Loading branch information
stapelberg committed May 26, 2010
1 parent 30b275d commit f6227be
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions i3-wsbar
Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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,
Expand All @@ -65,6 +82,8 @@ sub connected {
return;
}

$w = undef;

$i3->subscribe({
workspace => \&ws_change,
output => \&output_change,
Expand Down

0 comments on commit f6227be

Please sign in to comment.