Skip to content

Instantly share code, notes, and snippets.

@sulincix
Created April 25, 2024 23:25
Show Gist options
  • Save sulincix/cbe98f1cde19af50a078e327a12eb80f to your computer and use it in GitHub Desktop.
Save sulincix/cbe98f1cde19af50a078e327a12eb80f to your computer and use it in GitHub Desktop.
python window manager for kiosks
#!/usr/bin/python3
from Xlib import X, display
from Xlib import Xatom
class SimpleWindowManager:
def __init__(self):
self.display = display.Display()
self.root = self.display.screen().root
self.displayWidth = self.display.screen().width_in_pixels
self.displayHeight = self.display.screen().height_in_pixels
self.root.change_attributes(event_mask=X.SubstructureRedirectMask)
def run(self):
while True:
event = self.display.next_event()
print(event)
if event.type == X.MapRequest:
window = event.window
window.map()
window.configure(x=0, y=0, width=self.displayWidth, height=self.displayHeight)
window.set_input_focus(X.RevertToParent, X.CurrentTime)
elif event.type == X.ConfigureRequest:
window = event.window
window.configure(x=event.x, y=event.y, width=event.width, height=event.height)
if __name__ == "__main__":
wm = SimpleWindowManager()
wm.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment