summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/desktop/i3status-wrapper19
1 files changed, 10 insertions, 9 deletions
diff --git a/scripts/desktop/i3status-wrapper b/scripts/desktop/i3status-wrapper
index 4e0ddca9..22f01015 100755
--- a/scripts/desktop/i3status-wrapper
+++ b/scripts/desktop/i3status-wrapper
@@ -324,10 +324,7 @@ unless (fork // warn "couldn't fork command pipe reader") {
$mv->($i-1);
}
} elsif ($cmd eq "monocle toggle\n") {
- if (my $m = $ws->{monocle}) {
- undef $ws->{monocle};
- normalise_ws_cols(abs ++$m);
- } else {
+ unless (ensure_disable_monocle($ws)) {
$ws->{monocle} = -$i-1;
normalise_ws_cols();
}
@@ -671,11 +668,7 @@ sub fresh_workspace {
# its monocle mode container, then that workspace will get an empty
# event, and we'll lose track of any windows pushed off to the sides.
# So turn off monocle mode first.
- my $ws = $info{paper_ws}{$info{focused_ws}};
- if (my $m = $ws->{monocle}) {
- undef $ws->{monocle};
- normalise_ws_cols(abs ++$m);
- }
+ ensure_disable_monocle(my $ws = $info{paper_ws}{$info{focused_ws}});
# We need to ensure that the monitoring loop doesn't process the move
# event before it knows about the workspace change. Otherwise, that
@@ -757,6 +750,14 @@ sub node_first_child {
return $child_id;
}
+sub ensure_disable_monocle {
+ my $ws = shift;
+ my $m = $ws->{monocle} or return 0;
+ undef $ws->{monocle};
+ normalise_ws_cols(abs ++$m);
+ return 1;
+}
+
sub sorted_paper_ws {
sort { ws_num($info{paper_ws}{$a}{name})
<=> ws_num($info{paper_ws}{$b}{name}) }