summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2024-02-21 20:28:48 +0800
committerSean Whitton <spwhitton@spwhitton.name>2024-02-21 21:21:42 +0800
commite713faaccc850b3df6b534c7e85ebc4976b7872d (patch)
tree8b9dbc3b8f43d581c748cb5a4822cee26a828e05
parent8f17340143c6e259d6344c704426f3249d53b6a0 (diff)
downloaddotfiles-e713faaccc850b3df6b534c7e85ebc4976b7872d.tar.gz
i3status-wrapper: add wrapper for (move to) next/prev workspace cmds
-rw-r--r--.config/sway/config18
-rwxr-xr-xscripts/desktop/i3status-wrapper21
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;
}
}