-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·41 lines (30 loc) · 959 Bytes
/
main.py
File metadata and controls
executable file
·41 lines (30 loc) · 959 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2026 Furi Labs
#
# Authors:
# Bardia Moshiri <bardia@furilabs.com>
# Jesús Higueras <jesus@furilabs.com>
import gi
import time
from asyncio import run, sleep
from gi.repository import GLib, Gio
from external_displays import ExternalDisplays
async def pump_gtk_events():
main_context = GLib.MainContext.default()
app = ExternalDisplays(application_id="io.furios.ExternalDisplays")
app.connect('shutdown', lambda _: exit(0))
Gio.Application.set_default(app)
app.register()
app.activate()
frame_time = 1 / (240)
while True:
start_time = time.time()
while main_context.pending():
main_context.iteration(False)
elapsed = time.time() - start_time
remaining = max(0, frame_time - elapsed)
if remaining > 0:
await sleep(remaining)
if __name__ == "__main__":
run(pump_gtk_events())