From 684814a570bcf0bc0b5264fc05101446620d2bbc Mon Sep 17 00:00:00 2001 From: surtur Date: Mon, 5 Oct 2020 18:25:46 +0200 Subject: [PATCH] feat: sway workspace switcher (swws) logic update --- bin/swws.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/bin/swws.py b/bin/swws.py index 57f7c65..ae8afc1 100755 --- a/bin/swws.py +++ b/bin/swws.py @@ -10,6 +10,12 @@ else: a = "" ws = args[1] ws10 = str(10+int(ws)) +monnum = (subprocess.run(["bash", "-c", "swaymsg -t get_outputs| grep type | grep output | wc -l|xargs"],stdout=subprocess.PIPE)).stdout.decode('utf-8').rstrip() +if (monnum == "2"): + ws20 = ws10 +else: + ws20 = str(20+int(ws)) + msg = json.loads(subprocess.run(["swaymsg", "-t", "get_workspaces"], stdout=subprocess.PIPE).stdout.decode('utf-8')) def expl_pick(mon_type): @@ -62,7 +68,19 @@ for i in range(len(msg)): wssw(mon_type) if msg[i]["output"] == "DP-3": if not a: - subprocess.run(["swaymsg", "workspace", ws10]) + subprocess.run(["swaymsg", "workspace", ws20]) else: mon_type = "DP-3" wssw(mon_type) + if msg[i]["output"] == "DP-4": + if not a: + subprocess.run(["swaymsg", "workspace", ws10]) + else: + mon_type = "DP-4" + wssw(mon_type) + if msg[i]["output"] == "DP-5": + if not a: + subprocess.run(["swaymsg", "workspace", ws10]) + else: + mon_type = "DP-5" + wssw(mon_type)