Switch visibility in i3wm between two sets of workspaces based on which set is visible at the moment. Answer to this question: https://www.reddit.com/r/i3wm/comments/58545w/switching_multiple_workspaces_in_one_click/
Use quotes for the workspace name if it is not a number (e.g., "2:www").
#!/usr/bin/env python3
import json
import subprocess
stdout = subprocess.run(["i3-msg", "-t", "get_workspaces"], stdout=subprocess.PIPE).stdout.decode("utf-8")
workspaces = json.loads(stdout)
for w in workspaces:
if ((w["name"] == 1 or w["name"] == 3) and w["visible"]):
subprocess.run(["i3-msg", "workspace 2; workspace 4"])
break
elif ((w["name"] == 2 or w["name"] == 4) and w["visible"]):
subprocess.run(["i3-msg", "workspace 1; workspace 3"])
break