fix: register SteamVR only during a DroidDeck VR session (#1137)

This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-10-19 12:31:23 -04:00
1 parent 2415ff0518
commit a789d60f6a
3 files changed
+61 -1

No files matched your search

@@ -129,6 +129,7 @@ export XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
export XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache}
mkdir -p "$XDG_DATA_HOME" "$XDG_CONFIG_HOME" "$XDG_CACHE_HOME"
rm -f "${XDG_RUNTIME_DIR:-/run/droiddeck}/droiddeck-steamvr/active"
/usr/local/bin/droiddeck-steamvr unregister >/dev/null 2>&1 || true
if [ "$mode" = lxqt ] || [ "$mode" = desktop ]; then
/usr/local/bin/droiddeck-desktop-bookmarks || true
fi
@@ -41,6 +41,22 @@ configure_graphics() {
esac
}
# Any OpenXR probe (Steam runs one through Proton at every client start) starts vrserver
# while a runtime is registered, so SteamVR is registered only during a DroidDeck VR session.
unregister() {
if grep -qF "\"$steamvr\"" "$HOME/.config/openvr/openvrpaths.vrpath" 2>/dev/null; then
rm -f "$HOME/.config/openvr/openvrpaths.vrpath"
fi
case "$(readlink "$HOME/.config/openxr/1/active_runtime.json" 2>/dev/null)" in
"$steamvr"/*) rm -f "$HOME/.config/openxr/1/active_runtime.json" ;;
esac
}
idle() {
[ ! -f "$state/active" ] && ! running && ! pgrep -x vrstartup >/dev/null 2>&1 &&
( flock -n 9 ) 9>"$state/start.lock"
}
stop() {
rm -f "$state/active"
for n in vrcompositor vrserver vrmonitor vrdashboard vrstartup vrwebhelper; do
@@ -56,6 +72,7 @@ stop() {
[ "$attempts" -lt 20 ] || { echo 'SteamVR did not stop; preferences remain backed up' >&2; return 1; }
sleep 0.1
done
unregister
quest_settings restore
}
@@ -74,6 +91,7 @@ status)
i=0; installed && i=1
r=0; running && r=1
if [ "$r" = 0 ] && [ -n "$(find "$state/active" -mmin +2 2>/dev/null)" ]; then rm -f "$state/active"; fi
if idle; then unregister; fi
n=0; [ -f "$state/installing" ] && n=1
d=0; [ -f "$driver/bin/linuxarm64/driver_droiddeck.so" ] && [ -f "$layer/libVkLayer_droiddeck_vr.so" ] && d=1
echo "installed=$i running=$r installing=$n driver=$d"
@@ -100,6 +118,9 @@ install)
stop)
stop || exit 1
;;
unregister)
if idle; then unregister; fi
;;
start)
exec 9>"$state/start.lock"
flock -n 9 || { echo "SteamVR start already in progress"; exit 0; }
@@ -234,7 +255,7 @@ JSON
echo "SteamVR starting; logs in $logs and $state/vrstartup.log"
;;
*)
echo "usage: droiddeck-steamvr status|install|start|stop|launch" >&2
echo "usage: droiddeck-steamvr status|install|start|stop|launch|unregister" >&2
exit 2
;;
esac
+38
View File
@@ -210,6 +210,44 @@ class SteamVrHelperTest(unittest.TestCase):
def test_flat_presenter_does_not_enable_the_producer_lease(self):
self.assertIn('present=unset lease=unset', self.lease_log())
def registration(self):
return (self.home / '.config/openvr/openvrpaths.vrpath',
self.home / '.config/openxr/1/active_runtime.json')
def helper_action(self, action):
subprocess.run(['sh', str(self.helper), action], env=self.environment, check=True,
capture_output=True, timeout=5)
def test_runtime_is_registered_only_while_a_session_is_active(self):
vrpath, xr = self.registration()
self.start()
self.assertTrue(vrpath.is_file())
self.assertTrue(xr.is_symlink())
self.helper_action('status')
self.assertTrue(vrpath.is_file())
self.helper_action('stop')
self.assertFalse(vrpath.exists())
self.assertFalse(xr.is_symlink())
def test_idle_status_and_session_start_clear_a_leftover_registration(self):
vrpath, xr = self.registration()
for action in ('status', 'unregister'):
self.start()
(self.runtime / 'droiddeck-steamvr/active').unlink()
self.helper_action(action)
self.assertFalse(vrpath.exists(), action)
self.assertFalse(xr.is_symlink(), action)
def test_unregister_leaves_another_runtime_alone(self):
vrpath, xr = self.registration()
vrpath.parent.mkdir(parents=True)
xr.parent.mkdir(parents=True)
vrpath.write_text('{"runtime": ["/opt/other-runtime"]}')
xr.symlink_to('/opt/monado/openxr_monado.json')
self.helper_action('unregister')
self.assertTrue(vrpath.is_file())
self.assertTrue(xr.is_symlink())
if __name__ == '__main__':
unittest.main()