#!/usr/bin/env python3 import sys import subprocess import json I3_GET = ['i3-msg', '-t', 'get_workspaces'] I3_RENAME = ['i3-msg', 'rename', 'workspace', 'to'] def get(): for workspace in json.loads(subprocess.check_output(I3_GET)): if workspace['focused']: return workspace['name'] def filter(value): return subprocess.check_output([*sys.argv[1:], value]) def rename(value): subprocess.call([*I3_RENAME, value]) rename(filter(get()))