mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-08-05 02:34:48 +02:00
i3-companion: display tree for the current workspace
This helps to understand what's happening.
This commit is contained in:
parent
13e2c72123
commit
856ef13c02
2 changed files with 60 additions and 8 deletions
|
@ -219,9 +219,16 @@ async def quake_console(i3, event):
|
||||||
await i3.command(command)
|
await i3.command(command)
|
||||||
|
|
||||||
|
|
||||||
@on("info")
|
async def notify(*args):
|
||||||
async def window_info(i3, event):
|
"""Send a notification with notify-send."""
|
||||||
"""Show information about the focused window."""
|
proc = await asyncio.create_subprocess_exec(
|
||||||
|
"notify-send", *args)
|
||||||
|
await proc.communicate()
|
||||||
|
|
||||||
|
|
||||||
|
@on("container-info")
|
||||||
|
async def container_info(i3, event):
|
||||||
|
"""Show information about the focused container."""
|
||||||
tree = await i3.get_tree()
|
tree = await i3.get_tree()
|
||||||
window = tree.find_focused()
|
window = tree.find_focused()
|
||||||
if not window:
|
if not window:
|
||||||
|
@ -247,12 +254,56 @@ async def window_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))
|
||||||
proc = await asyncio.create_subprocess_exec(
|
await notify(
|
||||||
"notify-send",
|
|
||||||
"-i", "system-search",
|
"-i", "system-search",
|
||||||
|
"-t", "10000",
|
||||||
|
summary,
|
||||||
|
body)
|
||||||
|
|
||||||
|
|
||||||
|
@on("workspace-info")
|
||||||
|
async def workspace_info(i3, event):
|
||||||
|
"""Show information about the focused workspace."""
|
||||||
|
workspaces = await i3.get_workspaces()
|
||||||
|
focused = [w for w in workspaces if w.focused]
|
||||||
|
if not focused:
|
||||||
|
return
|
||||||
|
workspace = focused[0]
|
||||||
|
summary = f"About workspace {workspace.num} on {workspace.output}"
|
||||||
|
tree = await i3.get_tree()
|
||||||
|
workspace = [w for w in tree.workspaces()
|
||||||
|
if w.num == workspace.num]
|
||||||
|
|
||||||
|
def format(container):
|
||||||
|
if container.focused:
|
||||||
|
style = 'foreground="#ffaf00"'
|
||||||
|
else:
|
||||||
|
style = 'foreground="#6c98ee"'
|
||||||
|
root = (f"<span {style}>"
|
||||||
|
f"({container.layout})"
|
||||||
|
"</span>")
|
||||||
|
if container.window_title:
|
||||||
|
root += (f" {html.escape(container.window_class.lower())}:"
|
||||||
|
f" {html.escape(container.window_title)}")
|
||||||
|
children = []
|
||||||
|
for child in container.nodes:
|
||||||
|
if child == container.nodes[-1]:
|
||||||
|
first = "└─"
|
||||||
|
others = " "
|
||||||
|
else:
|
||||||
|
first = "├─"
|
||||||
|
others = "│ "
|
||||||
|
content = format(child).replace("\n", f"\n{others}")
|
||||||
|
children.append(f"<tt>{first}</tt>{content}")
|
||||||
|
children.insert(0, root)
|
||||||
|
return "\n".join(children)
|
||||||
|
|
||||||
|
body = format(workspace[0])
|
||||||
|
await notify(
|
||||||
|
"-i", "system-search",
|
||||||
|
"-t", "15000",
|
||||||
summary,
|
summary,
|
||||||
body)
|
body)
|
||||||
await proc.communicate()
|
|
||||||
|
|
||||||
|
|
||||||
output_update_running = None
|
output_update_running = None
|
||||||
|
|
5
config
5
config
|
@ -153,8 +153,9 @@ set $quake QuakeConsoleNeedsUniqueName
|
||||||
for_window [instance="$quake" title=$term] move window to scratchpad
|
for_window [instance="$quake" title=$term] move window to scratchpad
|
||||||
bindsym $mod+grave nop "quake-console:$term:$quake:0.3"
|
bindsym $mod+grave nop "quake-console:$term:$quake:0.3"
|
||||||
|
|
||||||
# Get info about an app (like xprop)
|
# Get info about container/workspace
|
||||||
bindsym $mod+i nop "info"
|
bindsym $mod+i nop "container-info"
|
||||||
|
bindsym $mod+Shift+i nop "workspace-info"
|
||||||
|
|
||||||
# Random rules
|
# Random rules
|
||||||
no_focus [window_type="splash"]
|
no_focus [window_type="splash"]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue