mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-21 21:46:07 +01:00
core: Move /tmp/hypr to $XDG_RUNTIME_DIR/hypr (#5788)
Moves the directory containing sockets and logs. Also restructures lockfiles a bit. For consumers, check if `$XDG_RUNTIME_DIR/hypr` exists. If so, use it. If not, use the old `/tmp/hypr`.
This commit is contained in:
parent
d20ee31210
commit
a5a6480917
9 changed files with 60 additions and 33 deletions
|
@ -34,16 +34,16 @@ If your bug crashes Hyprland, append additionally:
|
|||
## Obtaining the Hyprland log
|
||||
If you are in a TTY, and the hyprland session that crashed was the last one you launched, the log will be printed with
|
||||
```
|
||||
cat /tmp/hypr/$(ls -t /tmp/hypr/ | head -n 1)/hyprland.log
|
||||
cat $XDG_RUNTIME_DIR/hypr/$(ls -t $XDG_RUNTIME_DIR/hypr | head -n 1)/hyprland.log
|
||||
```
|
||||
feel free to send it to a file, save, copy, etc.
|
||||
|
||||
if you are in a Hyprland session, and you want the log of the last session, use
|
||||
```
|
||||
cat /tmp/hypr/$(ls -t /tmp/hypr/ | head -n 2 | tail -n 1)/hyprland.log
|
||||
cat $XDG_RUNTIME_DIR/hypr/$(ls -t $XDG_RUNTIME_DIR/hypr | head -n 2 | tail -n 1)/hyprland.log
|
||||
```
|
||||
|
||||
basically, directories in /tmp/hypr are your sessions.
|
||||
basically, directories in $XDG_RUNTIME_DIR/hypr are your sessions.
|
||||
|
||||
## Obtaining the Hyprland Crash Report (v0.22.0beta and up)
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/un.h>
|
||||
#include <pwd.h>
|
||||
#include <unistd.h>
|
||||
#include <ranges>
|
||||
#include <algorithm>
|
||||
|
@ -41,21 +42,22 @@ struct SInstanceData {
|
|||
std::vector<SInstanceData> instances() {
|
||||
std::vector<SInstanceData> result;
|
||||
|
||||
for (const auto& el : std::filesystem::directory_iterator("/tmp/hypr")) {
|
||||
if (el.is_directory() || !el.path().string().ends_with(".lock"))
|
||||
const std::string USERID = std::to_string(getpwuid(getuid())->pw_uid);
|
||||
|
||||
for (const auto& el : std::filesystem::directory_iterator("/run/user/" + USERID + "/hypr")) {
|
||||
if (!el.is_directory() || !std::filesystem::exists(el.path().string() + "/hyprland.lock"))
|
||||
continue;
|
||||
|
||||
// read lock
|
||||
SInstanceData* data = &result.emplace_back();
|
||||
data->id = el.path().string();
|
||||
data->id = data->id.substr(data->id.find_last_of('/') + 1, data->id.find(".lock") - data->id.find_last_of('/') - 1);
|
||||
|
||||
try {
|
||||
data->time = std::stoull(data->id.substr(data->id.find_first_of('_') + 1, data->id.find_last_of('_') - (data->id.find_first_of('_') + 1)));
|
||||
} catch (std::exception& e) { continue; }
|
||||
|
||||
// read file
|
||||
std::ifstream ifs(el.path().string());
|
||||
std::ifstream ifs(el.path().string() + "/hyprland.lock");
|
||||
|
||||
int i = 0;
|
||||
for (std::string line; std::getline(ifs, line); ++i) {
|
||||
|
@ -99,10 +101,12 @@ void request(std::string arg, int minArgs = 0) {
|
|||
return;
|
||||
}
|
||||
|
||||
sockaddr_un serverAddress = {0};
|
||||
serverAddress.sun_family = AF_UNIX;
|
||||
const std::string USERID = std::to_string(getpwuid(getuid())->pw_uid);
|
||||
|
||||
std::string socketPath = "/tmp/hypr/" + instanceSignature + "/.socket.sock";
|
||||
sockaddr_un serverAddress = {0};
|
||||
serverAddress.sun_family = AF_UNIX;
|
||||
|
||||
std::string socketPath = "/run/user/" + USERID + "/hypr/" + instanceSignature + "/.socket.sock";
|
||||
|
||||
strncpy(serverAddress.sun_path, socketPath.c_str(), sizeof(serverAddress.sun_path) - 1);
|
||||
|
||||
|
@ -160,7 +164,9 @@ void requestHyprpaper(std::string arg) {
|
|||
sockaddr_un serverAddress = {0};
|
||||
serverAddress.sun_family = AF_UNIX;
|
||||
|
||||
std::string socketPath = "/tmp/hypr/" + instanceSignature + "/.hyprpaper.sock";
|
||||
const std::string USERID = std::to_string(getpwuid(getuid())->pw_uid);
|
||||
|
||||
std::string socketPath = "/run/user/" + USERID + "/hypr/" + instanceSignature + "/.hyprpaper.sock";
|
||||
|
||||
strncpy(serverAddress.sun_path, socketPath.c_str(), sizeof(serverAddress.sun_path) - 1);
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
#include "protocols/FractionalScale.hpp"
|
||||
#include "protocols/PointerConstraints.hpp"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
int handleCritSignal(int signo, void* data) {
|
||||
Debug::log(LOG, "Hyprland received signal {}", signo);
|
||||
|
@ -62,6 +62,16 @@ void handleUserSignal(int sig) {
|
|||
CCompositor::CCompositor() {
|
||||
m_iHyprlandPID = getpid();
|
||||
|
||||
m_szHyprTempDataRoot = std::string{getenv("XDG_RUNTIME_DIR")} + "/hypr";
|
||||
|
||||
if (m_szHyprTempDataRoot.starts_with("/hypr")) {
|
||||
std::cout << "Bailing out, XDG_RUNTIME_DIR is invalid\n";
|
||||
throw std::runtime_error("CCompositor() failed");
|
||||
}
|
||||
|
||||
if (!m_szHyprTempDataRoot.starts_with("/run/user"))
|
||||
std::cout << "[!!WARNING!!] XDG_RUNTIME_DIR looks non-standard. Proceeding anyways...\n";
|
||||
|
||||
std::random_device dev;
|
||||
std::mt19937 engine(dev());
|
||||
std::uniform_int_distribution<> distribution(0, INT32_MAX);
|
||||
|
@ -70,29 +80,31 @@ CCompositor::CCompositor() {
|
|||
|
||||
setenv("HYPRLAND_INSTANCE_SIGNATURE", m_szInstanceSignature.c_str(), true);
|
||||
|
||||
if (!std::filesystem::exists("/tmp/hypr"))
|
||||
mkdir("/tmp/hypr", S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX);
|
||||
else if (!std::filesystem::is_directory("/tmp/hypr")) {
|
||||
std::cout << "Bailing out, /tmp/hypr is not a directory\n";
|
||||
return;
|
||||
if (!std::filesystem::exists(m_szHyprTempDataRoot))
|
||||
mkdir(m_szHyprTempDataRoot.c_str(), S_IRWXU);
|
||||
else if (!std::filesystem::is_directory(m_szHyprTempDataRoot)) {
|
||||
std::cout << "Bailing out, " << m_szHyprTempDataRoot << " is not a directory\n";
|
||||
throw std::runtime_error("CCompositor() failed");
|
||||
}
|
||||
|
||||
const auto INSTANCEPATH = "/tmp/hypr/" + m_szInstanceSignature;
|
||||
m_szInstancePath = m_szHyprTempDataRoot + "/" + m_szInstanceSignature;
|
||||
|
||||
if (std::filesystem::exists(INSTANCEPATH)) {
|
||||
std::cout << "Bailing out, /tmp/hypr/$HIS exists??\n";
|
||||
return;
|
||||
if (std::filesystem::exists(m_szInstancePath)) {
|
||||
std::cout << "Bailing out, " << m_szInstancePath << " exists??\n";
|
||||
throw std::runtime_error("CCompositor() failed");
|
||||
}
|
||||
|
||||
if (mkdir(INSTANCEPATH.c_str(), S_IRWXU) < 0) {
|
||||
std::cout << "Bailing out, couldn't create /tmp/hypr/$HIS\n";
|
||||
return;
|
||||
if (mkdir(m_szInstancePath.c_str(), S_IRWXU) < 0) {
|
||||
std::cout << "Bailing out, couldn't create " << m_szInstancePath << "\n";
|
||||
throw std::runtime_error("CCompositor() failed");
|
||||
}
|
||||
|
||||
Debug::init(m_szInstanceSignature);
|
||||
Debug::init(m_szInstancePath);
|
||||
|
||||
Debug::log(LOG, "Instance Signature: {}", m_szInstanceSignature);
|
||||
|
||||
Debug::log(LOG, "Runtime directory: {}", m_szInstancePath);
|
||||
|
||||
Debug::log(LOG, "Hyprland PID: {}", m_iHyprlandPID);
|
||||
|
||||
Debug::log(LOG, "===== SYSTEM INFO: =====");
|
||||
|
@ -519,7 +531,7 @@ void CCompositor::initManagers(eManagersInitStage stage) {
|
|||
}
|
||||
|
||||
void CCompositor::createLockFile() {
|
||||
const auto PATH = "/tmp/hypr/" + m_szInstanceSignature + ".lock";
|
||||
const auto PATH = m_szInstancePath + "/hyprland.lock";
|
||||
|
||||
std::ofstream ofs(PATH, std::ios::trunc);
|
||||
|
||||
|
@ -529,7 +541,7 @@ void CCompositor::createLockFile() {
|
|||
}
|
||||
|
||||
void CCompositor::removeLockFile() {
|
||||
const auto PATH = "/tmp/hypr/" + m_szInstanceSignature + ".lock";
|
||||
const auto PATH = m_szInstancePath + "/hyprland.lock";
|
||||
|
||||
if (std::filesystem::exists(PATH))
|
||||
std::filesystem::remove(PATH);
|
||||
|
|
|
@ -74,8 +74,11 @@ class CCompositor {
|
|||
wlr_session_lock_manager_v1* m_sWLRSessionLockMgr;
|
||||
// ------------------------------------------------- //
|
||||
|
||||
std::string m_szHyprTempDataRoot = "";
|
||||
|
||||
std::string m_szWLDisplaySocket = "";
|
||||
std::string m_szInstanceSignature = "";
|
||||
std::string m_szInstancePath = "";
|
||||
std::string m_szCurrentSplash = "error";
|
||||
|
||||
std::vector<SP<CMonitor>> m_vMonitors;
|
||||
|
|
|
@ -1746,7 +1746,7 @@ void CHyprCtl::startHyprCtlSocket() {
|
|||
|
||||
sockaddr_un SERVERADDRESS = {.sun_family = AF_UNIX};
|
||||
|
||||
std::string socketPath = "/tmp/hypr/" + g_pCompositor->m_szInstanceSignature + "/.socket.sock";
|
||||
std::string socketPath = g_pCompositor->m_szInstancePath + "/.socket.sock";
|
||||
|
||||
strcpy(SERVERADDRESS.sun_path, socketPath.c_str());
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <iostream>
|
||||
|
||||
void Debug::init(const std::string& IS) {
|
||||
logFile = "/tmp/hypr/" + IS + (ISDEBUG ? "/hyprlandd.log" : "/hyprland.log");
|
||||
logFile = IS + (ISDEBUG ? "/hyprlandd.log" : "/hyprland.log");
|
||||
}
|
||||
|
||||
void Debug::wlrLog(wlr_log_importance level, const char* fmt, va_list args) {
|
||||
|
|
|
@ -97,8 +97,13 @@ int main(int argc, char** argv) {
|
|||
|
||||
// let's init the compositor.
|
||||
// it initializes basic Wayland stuff in the constructor.
|
||||
g_pCompositor = std::make_unique<CCompositor>();
|
||||
g_pCompositor->explicitConfigPath = configPath;
|
||||
try {
|
||||
g_pCompositor = std::make_unique<CCompositor>();
|
||||
g_pCompositor->explicitConfigPath = configPath;
|
||||
} catch (std::exception& e) {
|
||||
std::cout << "Hyprland threw in ctor: " << e.what() << "\nCannot continue.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_pCompositor->initServer();
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ void CEventManager::startThread() {
|
|||
}
|
||||
|
||||
sockaddr_un SERVERADDRESS = {.sun_family = AF_UNIX};
|
||||
std::string socketPath = "/tmp/hypr/" + g_pCompositor->m_szInstanceSignature + "/.socket2.sock";
|
||||
std::string socketPath = g_pCompositor->m_szInstancePath + "/.socket2.sock";
|
||||
strncpy(SERVERADDRESS.sun_path, socketPath.c_str(), sizeof(SERVERADDRESS.sun_path) - 1);
|
||||
|
||||
bind(m_iSocketFD, (sockaddr*)&SERVERADDRESS, SUN_LEN(&SERVERADDRESS));
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "../debug/Log.hpp"
|
||||
#include "../helpers/VarList.hpp"
|
||||
#include "../managers/TokenManager.hpp"
|
||||
#include "../Compositor.hpp"
|
||||
|
||||
#define register
|
||||
#include <udis86.h>
|
||||
|
@ -138,7 +139,7 @@ CFunctionHook::SAssembly CFunctionHook::fixInstructionProbeRIPCalls(const SInstr
|
|||
currentAddress += len;
|
||||
}
|
||||
|
||||
const auto RANDOMDIR = "/tmp/hypr/" + g_pTokenManager->getRandomUUID();
|
||||
const auto RANDOMDIR = g_pCompositor->m_szInstancePath + "/" + g_pTokenManager->getRandomUUID();
|
||||
|
||||
if (std::filesystem::exists(RANDOMDIR)) {
|
||||
Debug::log(ERR, "[hooksystem] random out dir exists??");
|
||||
|
|
Loading…
Reference in a new issue