]> git.sur5r.net Git - i3/i3.github.io/blobdiff - docs/user-contributed/swapping-workspaces.html
Fix swapping workspaces script colon issue
[i3/i3.github.io] / docs / user-contributed / swapping-workspaces.html
index 75747f9e98968a65a6d7af1db38a7b89dbbb8fbb..e91fd7cc21e916fa98fb461ad0f5d40b2e1a3973 100644 (file)
@@ -23,17 +23,12 @@ workspace to the other monitor.
 <pre><tt>#!/usr/bin/env bash
 # requires jq
 
-DISPLAY_CONFIG=($(i3-msg -t get_outputs | jq -r '.[]|"\(.name):\(.current_workspace)"'))
-
-for ROW in "${DISPLAY_CONFIG[@]}"
-do
-    IFS=':'
-    read -ra CONFIG <<< "${ROW}"
-    if [ "${CONFIG[0]}" != "null" ] && [ "${CONFIG[1]}" != "null" ]; then
-        echo "moving ${CONFIG[1]} right..."
-        i3-msg workspace "${CONFIG[1]}"
-        i3-msg move workspace to output right  
-    fi
+IFS=:
+i3-msg -t get_outputs | jq -r '.[]|"\(.name):\(.current_workspace)"' | grep -v '^null:null$' | \
+while read -r name current_workspace; do
+    echo "moving ${current_workspace} right..."
+    i3-msg workspace "${current_workspace}"
+    i3-msg move workspace to output right   
 done</tt></pre>
 
 <p>