i3 bind swap workspaces
This commit is contained in:
parent
ff3d5064b8
commit
c3a1612b0f
@ -11,7 +11,7 @@ ssh:
|
||||
git:.config/git
|
||||
ranger:.config/ranger
|
||||
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
|
||||
font:
|
||||
termux:.termux
|
||||
|
||||
@ -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+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
|
||||
workspace $ws1 output primary
|
||||
|
||||
26
home/user/.local/bin/i3_swap_workspaces
Executable file
26
home/user/.local/bin/i3_swap_workspaces
Executable 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
|
||||
Loading…
x
Reference in New Issue
Block a user