Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add $HOME/.local/share/slimevr to the possible dirs of the sockets (fix #43) #44

Merged
merged 5 commits into from
Apr 25, 2024
Merged
Changes from 2 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
20 changes: 17 additions & 3 deletions src/bridge/bridge-unix-sockets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <filesystem>

#define TMP_DIR "/tmp"
#define SLIMEVR_HOME_LOCAL_DIR ".local/share/slimevr"
kitlith marked this conversation as resolved.
Show resolved Hide resolved
ImUrX marked this conversation as resolved.
Show resolved Hide resolved
#define SOCKET_NAME "SlimeVRDriver"

namespace fs = std::filesystem;
Expand Down Expand Up @@ -156,12 +157,25 @@ bool sendBridgeMessage(messages::ProtobufMessage& message, SlimeVRDriver::VRDriv
BridgeStatus runBridgeFrame(SlimeVRDriver::VRDriver& driver) {
try {
if (!client.IsOpen()) {
fs::path socket;
// TODO: do this once in the constructor or something
if(const char* ptr = std::getenv("XDG_RUNTIME_DIR")) {
const fs::path xdg_runtime = ptr;
client.Open((xdg_runtime / SOCKET_NAME).native());
} else {
client.Open((fs::path(TMP_DIR) / SOCKET_NAME).native());
socket = (xdg_runtime / SOCKET_NAME);
}
if(!fs::exists(socket)) {
socket = (fs::path(TMP_DIR) / SOCKET_NAME);
}
// try using home dir if the vrserver is run in a chroot like
if(!fs::exists(socket)) {
if(const char* ptr = std::getenv("HOME")) {
const fs::path home = ptr;
socket = (home / SLIMEVR_HOME_LOCAL_DIR / SOCKET_NAME);
}
ImUrX marked this conversation as resolved.
Show resolved Hide resolved
}
if(fs::exists(socket)) {
driver.Log("bridge socket: " + std::string(socket));
client.Open(socket.native());
}
}
client.UpdateOnce();
Expand Down
Loading