i3 bind swap workspaces

This commit is contained in:
thek4n 2025-05-23 11:04:29 +03:00
parent ff3d5064b8
commit c3a1612b0f
3 changed files with 28 additions and 1 deletions

View File

@ -11,7 +11,7 @@ ssh:
git:.config/git git:.config/git
ranger:.config/ranger ranger:.config/ranger
gpg: gpg:
i3:.xinitrc .xprofile .Xresources .config/i3 .config/i3status .local/bin/i3status_wrapper .config/rofi .config/picom .local/bin/slm .local/bin/slm_rofi.sh .local/bin/power_rofi.sh .local/bin/i3_switch_workspace.sh .config/mimeapps.list .local/bin/screenshot i3:.xinitrc .xprofile .Xresources .config/i3 .config/i3status .local/bin/i3status_wrapper .config/rofi .config/picom .local/bin/slm .local/bin/slm_rofi.sh .local/bin/power_rofi.sh .local/bin/i3_switch_workspace.sh .config/mimeapps.list .local/bin/screenshot .local/bin/i3_swap_workspaces
bat:.config/bat bat:.config/bat
font: font:
termux:.termux termux:.termux

View File

@ -232,6 +232,7 @@ bindsym Shift+Print exec --no-startup-id screenshot select save
bindsym Shift+$mod+Print exec --no-startup-id screenshot window save bindsym Shift+$mod+Print exec --no-startup-id screenshot window save
bindsym Shift+Ctrl+Print exec --no-startup-id screenshot entire save bindsym Shift+Ctrl+Print exec --no-startup-id screenshot entire save
bindsym $mod+s exec --no-startup-id i3_swap_workspaces
# default workspaces for monitors in setup # default workspaces for monitors in setup
workspace $ws1 output primary workspace $ws1 output primary

View File

@ -0,0 +1,26 @@
#!/bin/bash
set -eu
current_monitor=$(i3-msg -t get_workspaces | jq '.[] | select(.focused).output' | tr -d '"')
other_monitor=$(i3-msg -t get_outputs | jq -r ".[] | select(.active and .name != \"${current_monitor}\").name" | head -n 1)
if [ -z "${other_monitor}" ]; then
echo "No other active monitor found."
exit 1
fi
current_workspace=$(i3-msg -t get_workspaces | jq '.[] | select(.focused).name' | tr -d '"')
other_workspace=$(i3-msg -t get_workspaces | jq -r ".[] | select(.visible and .output == \"${other_monitor}\").name" | head -n 1)
if [ -n "${other_workspace}" ]; then
# Swap workspaces
i3-msg "workspace ${other_workspace}; move workspace to output ${current_monitor}"
i3-msg "workspace ${current_workspace}; move workspace to output ${other_monitor}"
i3-msg "workspace ${other_workspace}"
else
# Just move current workspace if target is empty
i3-msg "move workspace to output ${other_monitor}"
fi