mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-06-28 20:40:15 +02:00
i3-companion: also add a type for events from nop command
This commit is contained in:
parent
f454a74080
commit
f2e6173e30
1 changed files with 6 additions and 5 deletions
|
@ -32,6 +32,7 @@ DBusSignal = collections.namedtuple(
|
||||||
)
|
)
|
||||||
StartEvent = object()
|
StartEvent = object()
|
||||||
I3Event = i3ipc.Event
|
I3Event = i3ipc.Event
|
||||||
|
CommandEvent = collections.namedtuple("CommandEvent", ["name"])
|
||||||
|
|
||||||
|
|
||||||
NM_ACTIVE_CONNECTION_STATE_ACTIVATED = 2
|
NM_ACTIVE_CONNECTION_STATE_ACTIVATED = 2
|
||||||
|
@ -147,7 +148,7 @@ async def _new_workspace(i3):
|
||||||
return available
|
return available
|
||||||
|
|
||||||
|
|
||||||
@on("new-workspace", "move-to-new-workspace")
|
@on(CommandEvent("new-workspace"), CommandEvent("move-to-new-workspace"))
|
||||||
async def new_workspace(i3, event):
|
async def new_workspace(i3, event):
|
||||||
"""Create a new workspace and optionally move a window to it."""
|
"""Create a new workspace and optionally move a window to it."""
|
||||||
# Get the currently focused window
|
# Get the currently focused window
|
||||||
|
@ -218,7 +219,7 @@ async def worksplace_exclusive(i3, event):
|
||||||
await w.command(f'move container to workspace number "{num}"')
|
await w.command(f'move container to workspace number "{num}"')
|
||||||
|
|
||||||
|
|
||||||
@on("quake-console")
|
@on(CommandEvent("quake-console"))
|
||||||
async def quake_console(i3, event):
|
async def quake_console(i3, event):
|
||||||
"""Spawn a quake console or toggle an existing one."""
|
"""Spawn a quake console or toggle an existing one."""
|
||||||
try:
|
try:
|
||||||
|
@ -262,7 +263,7 @@ async def quake_console(i3, event):
|
||||||
await i3.command(command)
|
await i3.command(command)
|
||||||
|
|
||||||
|
|
||||||
@on("container-info")
|
@on(CommandEvent("container-info"))
|
||||||
async def container_info(i3, event):
|
async def container_info(i3, event):
|
||||||
"""Show information about the focused container."""
|
"""Show information about the focused container."""
|
||||||
tree = await i3.get_tree()
|
tree = await i3.get_tree()
|
||||||
|
@ -305,7 +306,7 @@ async def container_info(i3, event):
|
||||||
container_info.last_id = result[0]
|
container_info.last_id = result[0]
|
||||||
|
|
||||||
|
|
||||||
@on("workspace-info")
|
@on(CommandEvent("workspace-info"))
|
||||||
async def workspace_info(i3, event):
|
async def workspace_info(i3, event):
|
||||||
"""Show information about the focused workspace."""
|
"""Show information about the focused workspace."""
|
||||||
workspaces = await i3.get_workspaces()
|
workspaces = await i3.get_workspaces()
|
||||||
|
@ -593,7 +594,7 @@ async def main(options):
|
||||||
kind = cmd.split(":")[0]
|
kind = cmd.split(":")[0]
|
||||||
for fn, events in on.functions.items():
|
for fn, events in on.functions.items():
|
||||||
for e in events:
|
for e in events:
|
||||||
if e == kind:
|
if isinstance(e, CommandEvent) and e.name == kind:
|
||||||
await fn(i3, cmd)
|
await fn(i3, cmd)
|
||||||
|
|
||||||
i3.on(I3Event.BINDING, binding_event)
|
i3.on(I3Event.BINDING, binding_event)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue