-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathswitch-openvr-runtime.sh
executable file
·55 lines (50 loc) · 1.89 KB
/
switch-openvr-runtime.sh
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
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
function switch-openvr-runtime() {
# Get current runtime
current_runtime_target=$(readlink -f $HOME/.config/openvr/openvrpaths.vrpath)
if [[ "$current_runtime_target" == *opencomp* ]]; then
current_runtime="OpenComposite"
elif [[ "$current_runtime_target" == *steamvr* ]]; then
current_runtime="SteamVR"
else
current_runtime="Default (SteamVR?)"
fi
# Help
if [ -z "$1" ] || [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]]; then
echo "Usage: switch-openvr-runtime.sh [RUNTIME]"
echo "Runtimes:"
echo "- steamvr: Enable SteamVR OpenVR runtime"
echo "- opencomposite: Enable OpenComposite OpenVR translation layer"
echo "Currently enabled: $current_runtime"
return 1
fi
# Switching
if [[ "$1" == "steam" ]] || [[ "$1" == "steamvr" ]]; then
echo "Switching OpenVR runtime to SteamVR..."
ln -sf $HOME/.config/openvr/openvrpaths.vrpath.steamvr $HOME/.config/openvr/openvrpaths.vrpath
_result=$?
if [ $_result -eq 0 ]; then
echo "Now using SteamVR!"
return 0
else
echo "Failed to switch! Ensure SteamVR config exists."
return 1
fi
elif [[ "$1" == "opencomp" ]] || [[ "$1" == "opencomposite" ]]; then
echo "Switching OpenVR runtime to OpenComposite..."
ln -sf $HOME/.config/openvr/openvrpaths.vrpath.opencomp $HOME/.config/openvr/openvrpaths.vrpath
chmod 444 $HOME/.config/openvr/openvrpaths.vrpath.opencomp
_result=$?
if [ $_result -eq 0 ]; then
echo "Now using OpenComposite!"
return 0
else
echo "Failed to switch! Ensure OpenComposite config exists."
return 1
fi
else
echo "Invalid runtime value \"\". See \"switch-openvr-runtime.sh --help\"."
return 1
fi
}
switch-openvr-runtime "$*"