Compare commits
No commits in common. "c10b9fdb668be712630f76073ae385fdf213b749" and "53f8ca5eec558e257b58815ec3c45350c7e42b64" have entirely different histories.
c10b9fdb66
...
53f8ca5eec
2 changed files with 10 additions and 13 deletions
|
@ -23,8 +23,6 @@ Run multiple programs by specifying a yaml list of the form:
|
||||||
signal_continue: <a signal number upon which to move on to the next program, optional>
|
signal_continue: <a signal number upon which to move on to the next program, optional>
|
||||||
```
|
```
|
||||||
|
|
||||||
Not specifying a workspace implies that the program won't spawn a window.
|
|
||||||
|
|
||||||
## Installing
|
## Installing
|
||||||
|
|
||||||
Use the makefile: `INSTALL_BASE=/usr/local/ make install` or install all dependencies
|
Use the makefile: `INSTALL_BASE=/usr/local/ make install` or install all dependencies
|
||||||
|
@ -78,9 +76,11 @@ This could be combined with waybar to enforce an ordering of tray applications:
|
||||||
```yaml
|
```yaml
|
||||||
- program: 'nm-applet --indicator'
|
- program: 'nm-applet --indicator'
|
||||||
filter: '(False)'
|
filter: '(False)'
|
||||||
|
workspace: -1
|
||||||
signal_continue: 10
|
signal_continue: 10
|
||||||
- program: 'blueman-applet'
|
- program: 'blueman-applet'
|
||||||
filter: '(False)'
|
filter: '(False)'
|
||||||
|
workspace: -1
|
||||||
signal_continue: 10
|
signal_continue: 10
|
||||||
- ...
|
- ...
|
||||||
```
|
```
|
||||||
|
|
19
i3toolwait
19
i3toolwait
|
@ -297,9 +297,8 @@ async def wait_signal(s):
|
||||||
asyncio.get_running_loop().remove_signal_handler(s)
|
asyncio.get_running_loop().remove_signal_handler(s)
|
||||||
|
|
||||||
async def run(configs: list[dict], *, timeout: int, debug: bool):
|
async def run(configs: list[dict], *, timeout: int, debug: bool):
|
||||||
window_configs = [c for c in configs if c.get('workspace') is not None]
|
ipc = await i3ipc.aio.Connection().connect()
|
||||||
ipc = await i3ipc.aio.Connection().connect() # we only wait for configs which spawn a window
|
ipc.on('window::new', window_new(configs, debug=debug))
|
||||||
ipc.on('window::new', window_new(window_configs, debug=debug))
|
|
||||||
|
|
||||||
variables = {
|
variables = {
|
||||||
'pid': os.getpid(),
|
'pid': os.getpid(),
|
||||||
|
@ -319,9 +318,7 @@ async def run(configs: list[dict], *, timeout: int, debug: bool):
|
||||||
coroutines += [coro]
|
coroutines += [coro]
|
||||||
await asyncio.gather(*coroutines)
|
await asyncio.gather(*coroutines)
|
||||||
try:
|
try:
|
||||||
if window_configs:
|
await asyncio.wait_for(ipc.main(), timeout=timeout/1000)
|
||||||
# run main loop only if we wait for something
|
|
||||||
await asyncio.wait_for(ipc.main(), timeout=timeout/1000)
|
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
@ -337,7 +334,7 @@ def main(ctx, debug):
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
@click.option('--filter', '-f', default='True', help="A filter expression for the raw ipc dictionary.")
|
@click.option('--filter', '-f', default='True', help="A filter expression for the raw ipc dictionary.")
|
||||||
@click.option('--timeout', '-t', default=3000, help="Wait time for a window to appear (and match) in milliseconds.")
|
@click.option('--timeout', '-t', default=3000, help="Wait time for a window to appear (and match) in milliseconds.")
|
||||||
@click.option('--workspace', '-w', default=None, help="The workspace to move to.")
|
@click.option('--workspace', '-w', required=True, help="The workspace to move to.")
|
||||||
@click.argument('program', nargs=-1)
|
@click.argument('program', nargs=-1)
|
||||||
def simple(ctx, filter, timeout, workspace, program):
|
def simple(ctx, filter, timeout, workspace, program):
|
||||||
"""
|
"""
|
||||||
|
@ -355,8 +352,8 @@ def simple(ctx, filter, timeout, workspace, program):
|
||||||
@main.command()
|
@main.command()
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
@click.option('--timeout', '-t', default=3000, help="Wait time for a window to appear (and match) in milliseconds.")
|
@click.option('--timeout', '-t', default=3000, help="Wait time for a window to appear (and match) in milliseconds.")
|
||||||
@click.argument('config', type=click.File('r'), default='-')
|
@click.option('--configs', '-c', default='-', type=click.File('r'), help="A list of startup programs in json")
|
||||||
def config(ctx, timeout, config):
|
def config(ctx, timeout, configs):
|
||||||
"""
|
"""
|
||||||
Start a program and move it's created window to the desired i3 workspace.
|
Start a program and move it's created window to the desired i3 workspace.
|
||||||
|
|
||||||
|
@ -366,8 +363,8 @@ def config(ctx, timeout, config):
|
||||||
1 when no window has been found.
|
1 when no window has been found.
|
||||||
"""
|
"""
|
||||||
debug = ctx.obj['DEBUG']
|
debug = ctx.obj['DEBUG']
|
||||||
config = yaml.load(config, Loader=SafeLoader)
|
configs = yaml.load(configs, Loader=SafeLoader)
|
||||||
ctx.exit(asyncio.run(run(config, timeout=timeout, debug=debug)))
|
ctx.exit(asyncio.run(run(configs, timeout=timeout, debug=debug)))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue