Skip to content

Commit

Permalink
Expand possible socket dirs.
Browse files Browse the repository at this point in the history
  • Loading branch information
kitlith committed Jun 19, 2024
1 parent be11956 commit 33c4f05
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,28 @@ class UnixSocketBridge final : public SlimeVRBridge {

void connect() final {
if (!client.IsOpen()) {
fs::path socket;
// TODO: do this once in the constructor or something
if (const char* ptr = std::getenv("XDG_RUNTIME_DIR")) {
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("XDG_DATA_DIR")) {
const fs::path data_dir = ptr;
socket = (data_dir / SLIMEVR_DATA_DIR / SOCKET_NAME);

Check failure on line 156 in src/bridge.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-latest-Build Feeder App

‘SLIMEVR_DATA_DIR’ was not declared in this scope
} else if (const char* ptr = std::getenv("HOME")) {
const fs::path home = ptr;
socket = (home / XDG_DATA_DIR_DEFAULT / SLIMEVR_DATA_DIR / SOCKET_NAME);

Check failure on line 159 in src/bridge.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-latest-Build Feeder App

‘XDG_DATA_DIR_DEFAULT’ was not declared in this scope

Check failure on line 159 in src/bridge.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-latest-Build Feeder App

‘SLIMEVR_DATA_DIR’ was not declared in this scope
}
}
if(fs::exists(socket)) {
driver.Log("bridge socket: " + std::string(socket));

Check failure on line 163 in src/bridge.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-latest-Build Feeder App

‘driver’ was not declared in this scope
client.Open(socket.native());
}
}
}
Expand Down

0 comments on commit 33c4f05

Please sign in to comment.