Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions simulator/prepare-vm-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,12 @@ PY
# Packaged releases (0.3.2 on) install it in /usr/libexec, earlier ones in /usr/local/libexec.
session=$MOUNT/usr/libexec/arch-ipad-login-session
[[ -e $session ]] || session=$MOUNT/usr/local/libexec/arch-ipad-login-session
grep -q '^exec /usr/bin/labwc -m$' "$session" || { echo "$session: no Labwc start to hook" >&2; exit 1; }
sed -i 's|^exec /usr/bin/labwc -m$|# Orchard Simulator: the GPU desktop on Mesa software OpenGL (/etc/omarchy-a/simulator-gpu).\nif [[ -e /etc/omarchy-a/simulator-gpu ]]; then export WLR_RENDERER=gles2 WLR_RENDERER_ALLOW_SOFTWARE=1; unset QT_QUICK_BACKEND; fi\nexec /usr/bin/labwc -m|' "$session"
# The hook goes before Labwc starts: its `exec` in releases up to 0.3.x, the
# start-locked export (followed by the restart loop) since the session
# starts locked.
hook='^\(exec /usr/bin/labwc -m\|export OMARCHY_START_LOCKED=1\)$'
grep -q "$hook" "$session" || { echo "$session: no Labwc start to hook" >&2; exit 1; }
sed -i "\\%$hook%i # Orchard Simulator: the GPU desktop on Mesa software OpenGL (/etc/omarchy-a/simulator-gpu).\\nif [[ -e /etc/omarchy-a/simulator-gpu ]]; then export WLR_RENDERER=gles2 WLR_RENDERER_ALLOW_SOFTWARE=1; unset QT_QUICK_BACKEND; fi" "$session"
mkdir -p "$MOUNT/etc/omarchy-a"
touch "$MOUNT/etc/omarchy-a/simulator-gpu"

Expand Down
36 changes: 34 additions & 2 deletions simulator/vm-support/orchard-vm-bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,46 @@ def commands():
pass
elif line in (b'desktop gpu', b'desktop software'):
# The GPU desktop on software OpenGL, or the software desktop;
# the session starts again with it (back to the PIN screen).
# the session starts again with it (back to the lock screen).
flag = '/etc/omarchy-a/simulator-gpu'
if line == b'desktop gpu':
os.makedirs(os.path.dirname(flag), exist_ok=True)
open(flag, 'a').close()
elif os.path.exists(flag):
os.unlink(flag)
subprocess.run(['/usr/bin/systemctl', 'restart', 'greetd'], check=False)
restart_desktop()


def restart_desktop():
"""A new desktop session, as at boot.

greetd starts the desktop (initial_session) once per boot and notes that
in its runfile; restarted alone it would show its fallback instead. So
the old session ends, the note goes, and greetd starts the desktop
again, locked as at boot.
"""
subprocess.run(['/usr/bin/systemctl', 'stop', 'greetd'], check=False)
sessions = subprocess.run(['/usr/bin/loginctl', 'list-sessions', '--no-legend'],
capture_output=True, text=True, check=False).stdout
seat = [row.split()[0] for row in sessions.splitlines() if row.split()[3:4] == ['seat0']]
# With greetd stopped its sessions are abandoned: terminate-session only
# marks them closing (user processes outlive a session here), so their
# processes are signalled, and killed if they are not gone in 5 s.
for signal in ('SIGTERM', 'SIGKILL'):
for session in seat:
subprocess.run(['/usr/bin/loginctl', 'kill-session', session, f'--signal={signal}'],
capture_output=True, check=False)
deadline = time.monotonic() + 5
while time.monotonic() < deadline and subprocess.run(['/usr/bin/pgrep', '-x', 'labwc'],
capture_output=True).returncode == 0:
time.sleep(0.1)
for session in seat:
subprocess.run(['/usr/bin/loginctl', 'terminate-session', session], capture_output=True, check=False)
try:
os.unlink('/run/greetd.run')
except FileNotFoundError:
pass
subprocess.run(['/usr/bin/systemctl', 'start', 'greetd'], check=False)


threading.Thread(target=report_brightness, daemon=True).start()
Expand Down
Loading