diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2024-01-15 17:47:22 +0000 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2024-01-16 17:17:31 +0000 |
commit | 5a7cf7e3595c3a25c8885d40a0793228b80be7c1 (patch) | |
tree | 4a31c3948037e4d5272d44fe0bc0db4dcdca74ab | |
parent | 15733a679b7884e8253dc5dfbff1ef89f8879b4f (diff) | |
download | dotfiles-5a7cf7e3595c3a25c8885d40a0793228b80be7c1.tar.gz |
i3status-wrapper: implement simple monocle mode
-rw-r--r-- | .config/sway/config | 3 | ||||
-rwxr-xr-x | scripts/desktop/i3status-wrapper | 8 |
2 files changed, 8 insertions, 3 deletions
diff --git a/.config/sway/config b/.config/sway/config index f83746f6..4a1b5c25 100644 --- a/.config/sway/config +++ b/.config/sway/config @@ -282,7 +282,8 @@ bindsym Mod1+Ctrl+8 move down bindsym Mod1+Ctrl+9 move up bindsym Ctrl+5 kill -bindsym Ctrl+6 fullscreen toggle +bindsym Ctrl+6 exec \ + ~/src/dotfiles/scripts/desktop/i3status-wrapper-msg monocle toggle # bindsym Ctrl+apostrophe layout toggle splith splitv tabbed diff --git a/scripts/desktop/i3status-wrapper b/scripts/desktop/i3status-wrapper index 68b10e01..81e1e7cc 100755 --- a/scripts/desktop/i3status-wrapper +++ b/scripts/desktop/i3status-wrapper @@ -273,6 +273,10 @@ unless (fork // warn "couldn't fork command pipe reader") { } elsif ($i == $#$cols || $last_dir == 1) { $mv->($i-1); } + } elsif ($cmd eq "monocle toggle\n") { + $ws->{monocle} = !$ws->{monocle}; + normalise_ws_cols(); + kill USR1 => $i3status; } tied(%info)->unlock; @@ -411,7 +415,7 @@ sub normalise_ws_cols { my $i = first { $cols->[$_] eq $ws->{focused_col} } 0..$#$cols; my $mid_i = floor @$cols/2; # Pull column in if there are too few columns but some available. - if ($ws->{ncols} > @$cols + if (!$ws->{monocle} && $ws->{ncols} > @$cols && ($ws->{off_left}->@* || $ws->{off_right}->@*)) { if ($ws->{off_left}->@* # pull from left @@ -436,7 +440,7 @@ sub normalise_ws_cols { } } # Push a column off if there are too many columns. - elsif (@$cols > $ws->{ncols}) { + elsif (@$cols > $ws->{ncols} || $ws->{monocle} && @$cols > 1) { my $pushed = $i < $mid_i ? pop @$cols : shift @$cols; $wmipc->cmd(hide_con($pushed)); push $ws->{$i < $mid_i ? "off_right" : "off_left"}->@*, |