diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2024-01-14 16:07:56 +0000 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2024-01-14 16:07:56 +0000 |
commit | 22879583bf3ddea120315f15c7016734ff3a7106 (patch) | |
tree | bfea33954b30f154380f123eb61a3f5bc7d6091a | |
parent | 034cf4be2960cb09dd1efa4215638b9536916f3d (diff) | |
download | dotfiles-22879583bf3ddea120315f15c7016734ff3a7106.tar.gz |
i3status-wrapper: new_container: properly handle empty workspaces
-rwxr-xr-x | scripts/desktop/i3status-wrapper | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/scripts/desktop/i3status-wrapper b/scripts/desktop/i3status-wrapper index 6f3cb007..135a28ef 100755 --- a/scripts/desktop/i3status-wrapper +++ b/scripts/desktop/i3status-wrapper @@ -81,14 +81,18 @@ unless (fork // warn "couldn't fork monitoring loop") { # Leave it to a later loop iteration to update the focus. my $ws = $info{paper_ws}{$info{focused_ws}}; my $cols = $ws->{cols}; - my $i = first { $cols->[$_] == $ws->{focused_col} } 0..$#$cols; - splice $cols->@*, $i+1, 0, shift->{container}{id}; - if ($ws->{monocle} || $cols->@* > $ws->{ncols}) { - with_ignored_events { - my $pushed = shift $cols->@*; - $wmipc->cmd(hide_con($pushed)); - push $ws->{off_left}->@*, $pushed; - }; + if ($ws->{cols}->@*) { + my $i = first { $cols->[$_] == $ws->{focused_col} } 0..$#$cols; + splice $cols->@*, $i+1, 0, shift->{container}{id}; + if ($ws->{monocle} || $cols->@* > $ws->{ncols}) { + with_ignored_events { + my $pushed = shift $cols->@*; + $wmipc->cmd(hide_con($pushed)); + push $ws->{off_left}->@*, $pushed; + }; + } + } else { + push $ws->{cols}->@*, shift->{container}{id}; } } eval { |