use Getopt::Long;
use Pod::Usage;
use IPC::Run qw(start pump);
+use Try::Tiny;
use AnyEvent::I3;
use AnyEvent;
use v5.10;
}
my $x = $new{$name}->{rect}->{x};
+ my $w = $new{$name}->{rect}->{width};
my $launch = $command;
$launch =~ s/([^%])%x/$1$x/g;
+ $launch =~ s/([^%])%w/$1$w/g;
$launch =~ s/%%x/%x/g;
+ $launch =~ s/%%w/%w/g;
$new{$name}->{cmd_input} = '';
my @cmd = ('/bin/sh', '-c', $launch);
sub update_output {
my $dzen_bg = "#111111";
my $out;
+ my $previous_output;
for my $name (keys %{$outputs}) {
my $width = $outputs->{$name}->{rect}->{width};
+ $previous_output = undef;
$out = qq|^pa(;2)|;
for my $ws (@{$workspaces}) {
next if $ws->{output} ne $name and !$show_all;
+ # Display a separator if we are on a different output now
+ if (defined($previous_output) and
+ ($ws->{output} ne $previous_output)) {
+ $out .= qq|^fg(#900000)^ib(1)\|^ib(0)^p(+4)|;
+ }
+ $previous_output = $ws->{output};
+
my ($bg, $fg) = qw(333333 888888);
($bg, $fg) = qw(4c7899 ffffff) if $ws->{visible};
($bg, $fg) = qw(900000 ffffff) if $ws->{urgent};
- my $cmd = q|i3-msg "| . $ws->{num} . q|"|;
+ my $cmd = q|i3-msg "workspace | . $ws->{name} . q|"|;
my $name = $ws->{name};
# Begin the clickable area
$out .= qq|^p(2)^pa(;2)|;
}
- $out .= qq|^p(_LOCK_X)^fg($dzen_bg)^r(${width}x17)^p(_UNLOCK_X)^fg(white)|;
+ $out .= qq|^p(_LOCK_X)^fg($dzen_bg)^r(${width}x17)^p(_UNLOCK_X)^fg()|;
$out .= qq|^p(+5)|;
$out .= $last_line if (!@input_on or $name ~~ @input_on);
$out .= "\n";
$outputs->{$name}->{cmd_input} = $out;
- pump $outputs->{$name}->{cmd} while length $outputs->{$name}->{cmd_input};
+ try {
+ pump $outputs->{$name}->{cmd} while length $outputs->{$name}->{cmd_input};
+ } catch {
+ warn "Could not write to dzen2";
+ exit 1;
+ }
}
}
fh => \*STDIN,
poll => 'r',
cb => sub {
- chomp (my $line = <STDIN>);
+ my $line = <STDIN>;
+ if (!defined($line)) {
+ undef $stdin;
+ return;
+ }
+ chomp($line);
$last_line = $line;
update_output();
});
=item B<--command> <command>
This command (at the moment only dzen2 is supported) will be started for each
-output. C<%x> will be replaced with the X coordinate of the output.
+output. C<%x> will be replaced with the X coordinate of the output, C<%w> will
+be replaced with the width of the output.
Example:
- --command "dzen2 -dock -x %x"
+ --command "dzen2 -dock -x %x -w %w"
=item B<--input-on> <list-of-RandR-outputs>