25 lines
801 B
Python
Executable File
25 lines
801 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import subprocess
|
|
import re
|
|
|
|
import i3ipc
|
|
|
|
i3 = i3ipc.Connection()
|
|
workspaces = i3.get_workspaces()
|
|
focused = [ws for ws in workspaces if ws.focused]
|
|
|
|
if len(focused) == 1: # I have no idea when it wouldn't be, but whatever
|
|
inputName = subprocess.check_output(
|
|
['rofi', '-dmenu', '-l', '0', '-p', 'New name']).decode().strip()
|
|
oldNum = str(focused[0].num)
|
|
|
|
# basically either take raw input, allow clearing text part of a name,
|
|
# or add input to current number
|
|
# TODO: handle renaming of workspace without number to another name without a number
|
|
newName = inputName if re.match('^[0-9]+:', inputName) is not None else \
|
|
oldNum if inputName == "" else \
|
|
oldNum + ':' + inputName
|
|
|
|
i3.command(f"rename workspace to {newName}")
|