mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-06-30 13:24:21 +02:00
i3-companion: keep display open while running
This may be useful for some other uses. Notably, to achieve automatic layout, not unlike: https://gitlab.com/s3lect/awesome-i3-auto-layout/-/blob/master/awesome-auto-layout
This commit is contained in:
parent
c339655b4d
commit
6cf9a784f7
1 changed files with 22 additions and 22 deletions
|
@ -539,29 +539,28 @@ async def output_update(i3, event):
|
||||||
"""React to a XRandR change."""
|
"""React to a XRandR change."""
|
||||||
|
|
||||||
# Grab current setup. Synchronous, but it's short enough
|
# Grab current setup. Synchronous, but it's short enough
|
||||||
with contextlib.closing(display.Display()) as d:
|
screen = i3.x11.screen()
|
||||||
screen = d.screen()
|
window = screen.root.create_window(0, 0, 1, 1, 1, screen.root_depth)
|
||||||
window = screen.root.create_window(0, 0, 1, 1, 1, screen.root_depth)
|
screen_resources = randr.get_screen_resources_current(window)
|
||||||
screen_resources = randr.get_screen_resources_current(window)
|
current_setup = set()
|
||||||
current_setup = set()
|
for output in screen_resources.outputs:
|
||||||
for output in screen_resources.outputs:
|
output_info = randr.get_output_info(
|
||||||
output_info = randr.get_output_info(
|
window, output, screen_resources.timestamp
|
||||||
window, output, screen_resources.timestamp
|
)
|
||||||
)
|
if output_info.crtc == 0:
|
||||||
if output_info.crtc == 0:
|
continue
|
||||||
continue
|
crtc_info = randr.get_crtc_info(
|
||||||
crtc_info = randr.get_crtc_info(
|
window, output_info.crtc, output_info.timestamp
|
||||||
window, output_info.crtc, output_info.timestamp
|
)
|
||||||
)
|
current_setup.add(
|
||||||
current_setup.add(
|
(
|
||||||
(
|
output_info.name,
|
||||||
output_info.name,
|
crtc_info.width,
|
||||||
crtc_info.width,
|
crtc_info.height,
|
||||||
crtc_info.height,
|
crtc_info.x,
|
||||||
crtc_info.x,
|
crtc_info.y,
|
||||||
crtc_info.y,
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
# Compare to current setup
|
# Compare to current setup
|
||||||
if current_setup == output_update.last_setup:
|
if current_setup == output_update.last_setup:
|
||||||
|
@ -871,6 +870,7 @@ async def main(options):
|
||||||
i3 = await Connection(auto_reconnect=True).connect()
|
i3 = await Connection(auto_reconnect=True).connect()
|
||||||
i3.session_bus = await ravel.session_bus_async()
|
i3.session_bus = await ravel.session_bus_async()
|
||||||
i3.system_bus = await ravel.system_bus_async()
|
i3.system_bus = await ravel.system_bus_async()
|
||||||
|
i3.x11 = display.Display()
|
||||||
|
|
||||||
# Regular events
|
# Regular events
|
||||||
for fn, events in on.functions.items():
|
for fn, events in on.functions.items():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue