Skip to content

Commit

Permalink
use XDG_RUNTIME_DIR (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
ImUrX committed Feb 12, 2023
1 parent 8f1210a commit 63e263c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ cmake_minimum_required(VERSION 3.0.0)
endif()
#endif()

set (CMAKE_CXX_STANDARD 20)

# If the toolchain is already defined, do not attempt to find it
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
# If the VCPKG_ROOT environment variable is not defined, try to automatically define it from AppData/home
Expand Down
14 changes: 12 additions & 2 deletions src/bridge/bridge-unix-sockets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@
#include "unix-sockets.hpp"
#include <string_view>
#include <memory>
#include <cstdlib>
#include <filesystem>

#define SOCKET_PATH "/tmp/SlimeVRDriver"
#define TMP_DIR "/tmp"
#define SOCKET_NAME "SlimeVRDriver"

namespace fs = std::filesystem;
namespace {

inline constexpr int HEADER_SIZE = 4;
Expand Down Expand Up @@ -152,7 +156,13 @@ bool sendBridgeMessage(messages::ProtobufMessage& message, SlimeVRDriver::VRDriv
BridgeStatus runBridgeFrame(SlimeVRDriver::VRDriver& driver) {
try {
if (!client.IsOpen()) {
client.Open(SOCKET_PATH);
// 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());
}
}
client.UpdateOnce();

Expand Down

0 comments on commit 63e263c

Please sign in to comment.