6 <div id="content" class="usergen">
7 <h1>User-contributed article: Swapping workspaces</h1>
10 If you have workspace 1 on one monitor and workspace 2 on another monitor and
11 want to quickly swap the workspaces among the monitors, you can use i3's IPC
16 i3 already includes a way to move an individual workspace from one monitor to
17 another. But what we want to achieve is the <strong>simultaneous</strong>
18 movement of workspaces between the monitors. To do this, we can write a script
19 that detects the currently active workspace on each monitor and then moves that
20 workspace to the other monitor.
23 <pre><tt>#!/usr/bin/env bash
27 i3-msg -t get_outputs | jq -r '.[]|"\(.name):\(.current_workspace)"' | grep -v '^null:null$' | \
28 while read -r name current_workspace; do
29 echo "moving ${current_workspace} right..."
30 i3-msg workspace "${current_workspace}"
31 i3-msg move workspace to output right
35 To use this script, I recommend binding it to a keyboard shortcut in your i3 config:
37 <pre><tt>bindsym $mod+Shift+s exec /path/to/your/script/i3-display-swap.sh</tt></pre>
39 Now restart i3 in place. The next time you press mod+Shift+s, your workspaces will be swapped among your monitors.
42 <p>Source: <a href="https://gist.github.com/fbrinker/df9cfbc84511d807f45041737ff3ea02">Github</a></p>