Release Vulpes OS Preview 26 with Gecko 161.0 and Tundra 0.2.0
This commit is contained in:
parent
3a1fba4efe
commit
e241a42d2f
1 changed files with 1305 additions and 331 deletions
|
|
@ -107,21 +107,24 @@ def control(p):
|
|||
def set_session_idle(idle):
|
||||
"""Tell logind that Gaia has switched the display between active and idle."""
|
||||
try:
|
||||
result = subprocess.run(['/usr/bin/loginctl', 'list-sessions', '--no-legend', '--no-pager'],
|
||||
capture_output=True, text=True, timeout=3, check=True)
|
||||
sessions = []
|
||||
for line in result.stdout.splitlines():
|
||||
fields = line.split()
|
||||
if len(fields) >= 2 and fields[1] == '32011' and fields[0].isalnum():
|
||||
sessions.append(fields[0])
|
||||
bus = ['/usr/bin/busctl', '--system']
|
||||
service = 'org.freedesktop.login1'
|
||||
result = subprocess.run([*bus, '--json=short', 'call', service, '/org/freedesktop/login1',
|
||||
service + '.Manager', 'ListSessions'],
|
||||
capture_output=True, text=True, timeout=3, check=True)
|
||||
rows, = json.loads(result.stdout)['data']
|
||||
sessions = [path for _, uid, _, _, path in rows if uid == 32011]
|
||||
if not sessions:
|
||||
raise RuntimeError('No Tundra logind sessions found')
|
||||
value = 'true' if idle else 'false'
|
||||
for session in sessions:
|
||||
subprocess.run(['/usr/bin/busctl', '--system', 'call', 'org.freedesktop.login1',
|
||||
'/org/freedesktop/login1/session/'+session,
|
||||
'org.freedesktop.login1.Session', 'SetIdleHint', 'b', value],
|
||||
capture_output=True, text=True, timeout=3, check=True)
|
||||
failures = []
|
||||
for path in sessions:
|
||||
reply = subprocess.run([*bus, 'call', service, path, service + '.Session',
|
||||
'SetIdleHint', 'b', value], capture_output=True, text=True, timeout=3)
|
||||
if reply.returncode:
|
||||
failures.append(path + ' ' + reply.stderr.strip())
|
||||
if failures:
|
||||
raise RuntimeError(', '.join(failures))
|
||||
return True
|
||||
except (OSError, RuntimeError, subprocess.SubprocessError) as error:
|
||||
print('TUNDRA_LOGIND_IDLE_FAILED '+str(error), file=sys.stderr, flush=True)
|
||||
|
|
@ -149,7 +152,9 @@ def serve():
|
|||
fd = os.open('/dev/input/'+device.name, os.O_RDONLY | os.O_NONBLOCK)
|
||||
selector.register(fd, selectors.EVENT_READ)
|
||||
while True:
|
||||
timeout = max(0, min(1, vibration.deadline - time.monotonic())) if vibration.deadline is not None else 1
|
||||
timers = [t for t in (vibration.deadline, wake_recovery.deadline) if t is not None]
|
||||
timeout = max(0, min(timers) - time.monotonic()) if timers else None
|
||||
previous_sequence = state['sequence']
|
||||
for key, _ in selector.select(timeout):
|
||||
if key.fileobj is server:
|
||||
conn, _ = server.accept()
|
||||
|
|
@ -178,7 +183,8 @@ def serve():
|
|||
if vibration.deadline is not None:
|
||||
vibration.advance(time.monotonic())
|
||||
wake_recovery.advance(time.monotonic())
|
||||
publish()
|
||||
if previous_sequence != state['sequence']:
|
||||
publish()
|
||||
|
||||
def client():
|
||||
raw = sys.stdin.read(1024)
|
||||
|
|
|
|||
Loading…
Reference in a new issue