App-papersway
view release on metacpan or search on metacpan
bin/papersway view on Meta::CPAN
} elsif ($e->{change} eq "rename"
&& exists $paper_ws{$e->{current}{id}}) {
$paper_ws{$e->{current}{id}}{name} = $e->{current}{name};
signal_i3status();
} elsif ($e->{change} eq "move" && $e->{current}) {
$paper_ws{$e->{current}{id}}{output} = $e->{current}{output};
} elsif ($e->{change} eq "empty" && $e->{current}) {
delete $paper_ws{$e->{current}{id}};
signal_i3status();
}
},
# Update values in %output_init_cols and $paper_ws{*}{output} values.
output => sub { queue_event shift },
})->recv->{success} or die "couldn't subscribe to window manager events";
# Determine the initial state -- the WM might just have been reloaded.
# Move any previously-hidden containers to a fresh workspace for perusal.
my @old_ids;
for_each_node {
my $node = shift;
if ($node->{type} eq "output") {
sync_output($node);
} elsif ($node->{type} eq "workspace") {
if (grep $_ eq $node->{name}, @all_workspaces) {
my $entry = init_ws($node->{id}, name => $node->{name},
output => $node->{output});
sync_cols($node => $entry);
} elsif ($node->{name} =~ /\A\*(\d+)\*\z/) {
push @old_ids, map $_->{id}, $node->{floating_nodes}->@*;
}
} elsif (grep $_ eq "caffeinated", $node->{marks}->@*) {
register_caffeinated($node);
}
};
while (my ($id, $entry) = each %paper_ws) {
$entry->{ncols} = max $output_init_cols{$entry->{output}},
scalar $entry->{cols}->@*;
}
for ($wmipc->get_workspaces->recv->@*) {
$_->{focused} or next;
$focused_ws = $_->{id};
$last_focused_ws = $paper_ws{$focused_ws};
last;
}
if (@old_ids) {
fresh_workspace(go => 1);
$cmds->cmd(
map("[con_id=$_] move container workspace current, floating disable",
@old_ids), # ^^^^^^^^^^^^^^^^
# Somehow has no
# effect under i3.
"focus child");
}
$cmds->cmd("bar bar-0 workspace_buttons no")
if $have_sway && $i3status && !$debug && !$with_ws_cmd;
$cmds->flush;
debugsay "initialised";
debugdump [\%paper_ws], [qw(*paper_ws)];
my $username = $ENV{LOGNAME} || $ENV{USER} || getpwuid $<;
my $hostinfo = { name => "hostinfo",
full_text => sprintf "%s@%s", $username, hostname };
# Skip the first line which contains the version header.
print scalar <$pipe> if $i3status;
# The second line contains the start of the infinite array.
print scalar <$pipe> if $i3status;
# Basic idea here from Michael Stapelberg's sample i3status-wrapper.
my $i3status_wrapper = $i3status && AnyEvent->io(
fh => $pipe, poll => "r", cb => sub {
# If there is a decoding error then we just skip this line, as it's
# not worth crashing this script over that. It should be fine to do
# this here because this filtering loop is in itself stateless.
# It's only if the decoding error involves newlines in wrong places,
# or similar, that this skip could cause us to produce invalid output.
my ($statusline) = (<$pipe> =~ /^,?(.*)/);
my $blocks = eval { decode_json $statusline } // return;
if ($focused_ws && !$with_ws_cmd && keys %paper_ws > 1) {
my @disp;
foreach my $key (sorted_paper_ws()) {
push @disp,
sprintf +($focused_ws == $key ? "<b>%s</b>" : "%s"),
ws_name($paper_ws{$key}{name})
}
unshift @$blocks,
{ name => "ws", markup => "pango", full_text => "@disp" };
}
if ($focused_ws && exists $paper_ws{$focused_ws}) {
# â, â and äº are possible alternatives to â¡â¡.
sub nwin { join " ", map +(widep($_) ? "\x{2021}"x2 : "\x{2021}"),
@_ }
my $ws = $paper_ws{$focused_ws};
my @left = $ws->{off_left}->@*;
my @right = reverse $ws->{off_right}->@*;
my @cols = $ws->{cols}->@*;
my $disp;
if (!@left && !@right && (!@cols || !widep($cols[0]))) {
$disp = sprintf "<b>%s</b>",
join " ", ("\x{2021}")x$ws->ncols;
} else {
$disp = sprintf "<b>%s</b>", nwin(@cols);
$disp = sprintf "%s %s", nwin(@left), $disp if @left;
$disp = sprintf "%s %s", $disp, nwin(@right) if @right;
}
unshift @$blocks,
{ name => "cols", markup => "pango", full_text => $disp };
}
unshift @$blocks,
{ name => "caffeinated", full_text => "Caffeinated: $caffe_name" }
if $caffe_name;
unshift @$blocks, $hostinfo;
( run in 1.674 second using v1.01-cache-2.11-cpan-6aa56a78535 )