From e713faaccc850b3df6b534c7e85ebc4976b7872d Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 21 Feb 2024 20:28:48 +0800 Subject: i3status-wrapper: add wrapper for (move to) next/prev workspace cmds --- .config/sway/config | 18 +++++++++--------- scripts/desktop/i3status-wrapper | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/.config/sway/config b/.config/sway/config index 857f14da..55ccdbf8 100644 --- a/.config/sway/config +++ b/.config/sway/config @@ -272,18 +272,18 @@ bindsym Ctrl+6 exec \ # bindsym Ctrl+apostrophe layout toggle splith splitv tabbed -# Cycle through all workspaces on monitor. +# Cycle through all workspaces. # Warp the cursor to a point on the screen which is hopefully a titlebar. # This means that cycling through workspaces does not abruptly stop because, # e.g., a VNC client has grabbed the keyboard upon entry to the workspace. -bindsym Ctrl+1 seat - cursor set 0 0, workspace prev_on_output -bindsym Ctrl+4 seat - cursor set 0 0, workspace next_on_output -bindsym Mod1+Ctrl+1 seat - cursor set 0 0, \ - move container to workspace prev_on_output, \ - workspace prev_on_output -bindsym Mod1+Ctrl+4 seat - cursor set 0 0, \ - move container to workspace next_on_output, \ - workspace next_on_output +bindsym Ctrl+1 seat - cursor set 0 0, exec \ + ~/src/dotfiles/scripts/desktop/i3status-wrapper-msg workspace prev +bindsym Ctrl+4 seat - cursor set 0 0, exec \ + ~/src/dotfiles/scripts/desktop/i3status-wrapper-msg workspace next +bindsym Mod1+Ctrl+1 seat - cursor set 0 0, exec \ + ~/src/dotfiles/scripts/desktop/i3status-wrapper-msg move_workspace prev +bindsym Mod1+Ctrl+4 seat - cursor set 0 0, exec \ + ~/src/dotfiles/scripts/desktop/i3status-wrapper-msg move_workspace next bindsym Ctrl+2 focus output left bindsym Mod1+Ctrl+2 move workspace to output left diff --git a/scripts/desktop/i3status-wrapper b/scripts/desktop/i3status-wrapper index 22f01015..fb8d4e34 100755 --- a/scripts/desktop/i3status-wrapper +++ b/scripts/desktop/i3status-wrapper @@ -392,6 +392,27 @@ unless (fork // warn "couldn't fork command pipe reader") { } } + # Basic purpose of this wrapper command is to prevent accidentally + # moving to one of the holding workspaces using Sway's own commands. + elsif ($cmd =~ /^(move_)?workspace (prev|next)$/) { + my ($move, $dir) = (!!$1, $2); + $move && ensure_disable_monocle($ws); + my @keys = sorted_paper_ws(); + my $k = first { $keys[$_] == $info{focused_ws} } 0..$#keys; + if ($dir eq "next" && $k < $#keys || $dir eq "prev" && $k > 0) { + my @cmds = "workspace $dir"; + $info{focused_ws} = $keys[$dir eq "next" ? $k+1 : $k-1]; + if ($move) { + push @cmds, show_con($ws->{focused_col}); + push @cmds, "move right" + if $info{col_rows} + { $info{paper_ws}{$info{focused_ws}}{focused_col} }; + push @cmds, "focus child" if $col_rows; + } + $wmipc->cmd(@cmds); + } + } + tied(%info)->unlock; } } -- cgit v1.2.3