dotfiles/.local/bin/switchws.py

13 lines
462 B
Python
Executable File

#!/usr/bin/python
import json,sys,subprocess
args = sys.argv
msg = json.loads(subprocess.run(["swaymsg", "-t", "get_workspaces"], stdout=subprocess.PIPE).stdout.decode('utf-8'))
for i in range(len(msg)):
if msg[i]["focused"] == True:
if msg[i]["output"] == "DP-1":
subprocess.run(["swaymsg", "workspace", str(args[1])])
if msg[i]["output"] == "DVI-D-1":
subprocess.run(["swaymsg", "workspace", "P" + str(args[1])])