Handle initial parentheses, allow multiple arguments for program.

This commit is contained in:
redxef 2022-10-20 03:49:22 +02:00
parent 75087e5fdb
commit 29e9a455d8
Signed by: redxef
GPG key ID: 7DAC3AA211CBD921

View file

@ -167,6 +167,8 @@ def group_tokens(tokens: list[str]):
return groups return groups
def build_expression(tokens: list[str]) -> Expression: def build_expression(tokens: list[str]) -> Expression:
if tokens[0] == '(' and tokens[-1] == ')':
tokens = tokens[1:-1]
token_groups = group_tokens(tokens) token_groups = group_tokens(tokens)
expressions = [build_expression(ts) for ts in token_groups[1:]] if len(token_groups) > 1 else [] expressions = [build_expression(ts) for ts in token_groups[1:]] if len(token_groups) > 1 else []
@ -283,6 +285,8 @@ def main(filter, debug, workspace, program):
""" """
filter = parse(filter) filter = parse(filter)
program = ' '.join(program)
print(filter)
ipc = i3ipc.Connection() ipc = i3ipc.Connection()
ipc.on('window::new', window_new(filter, workspace=workspace, debug=debug)) ipc.on('window::new', window_new(filter, workspace=workspace, debug=debug))
ipc.command(f'exec {program}') ipc.command(f'exec {program}')