mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-06-23 10:18:34 +02:00
i3-companion: move notify helper function at top
This commit is contained in:
parent
f98b530813
commit
0984436348
1 changed files with 21 additions and 20 deletions
|
@ -34,6 +34,23 @@ def on(*events):
|
||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
|
async def notify(i3, **kwargs):
|
||||||
|
"""Send a notification with notify-send."""
|
||||||
|
peer = i3.session_bus["org.freedesktop.Notifications"]
|
||||||
|
peer = peer["/org/freedesktop/Notifications"]
|
||||||
|
interface = await peer.get_async_interface("org.freedesktop.Notifications")
|
||||||
|
parameters = dict(
|
||||||
|
app_name=logger.name,
|
||||||
|
replaces_id=0,
|
||||||
|
app_icon="dialog-information",
|
||||||
|
summary="",
|
||||||
|
actions=[],
|
||||||
|
hints={},
|
||||||
|
expire_timeout=5000)
|
||||||
|
parameters.update(kwargs)
|
||||||
|
return await interface.Notify(**parameters)
|
||||||
|
|
||||||
|
|
||||||
# See https://fontawesome.com/v5.15/icons
|
# See https://fontawesome.com/v5.15/icons
|
||||||
application_icons = {
|
application_icons = {
|
||||||
"chromium": "",
|
"chromium": "",
|
||||||
|
@ -222,22 +239,6 @@ async def quake_console(i3, event):
|
||||||
await i3.command(command)
|
await i3.command(command)
|
||||||
|
|
||||||
|
|
||||||
async def notify(bus, **kwargs):
|
|
||||||
"""Send a notification with notify-send."""
|
|
||||||
peer = bus["org.freedesktop.Notifications"]["/org/freedesktop/Notifications"]
|
|
||||||
interface = await peer.get_async_interface("org.freedesktop.Notifications")
|
|
||||||
parameters = dict(
|
|
||||||
app_name=logger.name,
|
|
||||||
replaces_id=0,
|
|
||||||
app_icon="dialog-information",
|
|
||||||
summary="",
|
|
||||||
actions=[],
|
|
||||||
hints={},
|
|
||||||
expire_timeout=5000)
|
|
||||||
parameters.update(kwargs)
|
|
||||||
return await interface.Notify(**parameters)
|
|
||||||
|
|
||||||
|
|
||||||
@on("container-info")
|
@on("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."""
|
||||||
|
@ -266,7 +267,7 @@ async def container_info(i3, event):
|
||||||
body = "\n".join((f"<tt>{k:10}</tt> {html.escape(str(v))}"
|
body = "\n".join((f"<tt>{k:10}</tt> {html.escape(str(v))}"
|
||||||
for k, v in info.items()
|
for k, v in info.items()
|
||||||
if v is not None))
|
if v is not None))
|
||||||
result = await notify(i3.session_bus,
|
result = await notify(i3,
|
||||||
app_icon="system-search",
|
app_icon="system-search",
|
||||||
expire_timeout=10000,
|
expire_timeout=10000,
|
||||||
summary=summary,
|
summary=summary,
|
||||||
|
@ -324,7 +325,7 @@ async def workspace_info(i3, event):
|
||||||
return "\n".join(children)
|
return "\n".join(children)
|
||||||
|
|
||||||
body = format(workspace[0]).lstrip("\n")
|
body = format(workspace[0]).lstrip("\n")
|
||||||
result = await notify(i3.session_bus,
|
result = await notify(i3,
|
||||||
app_icon="system-search",
|
app_icon="system-search",
|
||||||
expire_timeout=20000,
|
expire_timeout=20000,
|
||||||
summary=summary,
|
summary=summary,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue