From d56b44114a360f7e10f819db4c9da0fd324b2b10 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Sun, 11 Jul 2021 22:46:53 +0200 Subject: [PATCH] i3-companion: ensure variables are captured when wrapping event --- bin/i3-companion | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/bin/i3-companion b/bin/i3-companion index 37de0e6..81b0ec2 100755 --- a/bin/i3-companion +++ b/bin/i3-companion @@ -456,21 +456,23 @@ async def main(options): if isinstance(event, DBusSignal): for bus in {i3.session_bus, i3.system_bus}: - @ravel.signal( - name=event.member, - in_signature=event.signature, - path_keyword="path", - args_keyword="args", - ) - async def wrapped(path, args): - return await fn(i3, event, path, *args) + def wrapping(fn, event): + @ravel.signal( + name=event.member, + in_signature=event.signature, + path_keyword="path", + args_keyword="args", + ) + async def wrapped(path, args): + return await fn(i3, event, path, *args) + return wrapped bus.listen_signal( path=event.path, fallback=True, interface=event.interface, name=event.member, - func=wrapped, + func=wrapping(fn, event), ) await i3.main()