mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-07-10 10:14:20 +02:00
i3-companion: use monitors to detect RandR changes
This commit is contained in:
parent
c2e32d1824
commit
1a30417043
1 changed files with 16 additions and 20 deletions
|
@ -23,8 +23,9 @@ from i3ipc.aio import Connection
|
||||||
from systemd import journal
|
from systemd import journal
|
||||||
import ravel
|
import ravel
|
||||||
import dbussy
|
import dbussy
|
||||||
from Xlib import display
|
import xcffib
|
||||||
from Xlib.ext import randr
|
import xcffib.xproto
|
||||||
|
import xcffib.randr
|
||||||
|
|
||||||
|
|
||||||
def icon(font_number, char):
|
def icon(font_number, char):
|
||||||
|
@ -576,24 +577,19 @@ 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
|
||||||
screen = i3.x11.screen()
|
randr = i3.x11(xcffib.randr.key)
|
||||||
window = screen.root.create_window(0, 0, 1, 1, 1, screen.root_depth)
|
screen = i3.x11.get_setup().roots[0]
|
||||||
screen_resources = randr.get_screen_resources_current(window)
|
monitors = randr.GetMonitors(screen.root, 1).reply().monitors
|
||||||
current_setup = set()
|
current_setup = {
|
||||||
for output in screen_resources.outputs:
|
(
|
||||||
output_info = randr.get_output_info(window, output, screen_resources.timestamp)
|
i3.x11.core.GetAtomName(m.name).reply().name.to_string(),
|
||||||
if output_info.crtc == 0:
|
m.width,
|
||||||
continue
|
m.height,
|
||||||
crtc_info = randr.get_crtc_info(window, output_info.crtc, output_info.timestamp)
|
m.x,
|
||||||
current_setup.add(
|
m.y,
|
||||||
(
|
|
||||||
output_info.name,
|
|
||||||
crtc_info.width,
|
|
||||||
crtc_info.height,
|
|
||||||
crtc_info.x,
|
|
||||||
crtc_info.y,
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
for m in monitors
|
||||||
|
}
|
||||||
|
|
||||||
# Compare to current setup
|
# Compare to current setup
|
||||||
if current_setup == output_update.last_setup:
|
if current_setup == output_update.last_setup:
|
||||||
|
@ -894,7 +890,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()
|
i3.x11 = xcffib.connect()
|
||||||
|
|
||||||
# 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