aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/debug/CrashReporter.cpp
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2023-04-03 16:46:03 +0100
committervaxerski <[email protected]>2023-04-03 16:46:03 +0100
commit039a97adc8048f7d7ffbcc9f822b3cafdc50479c (patch)
treedb8a0ea733d92ed236353261a42a7c3906b960eb /src/debug/CrashReporter.cpp
parent49e7f357346e8a30077ac43d32eda37fc237136e (diff)
parente6211eef00a96c0dc7f8c06a6a151f5485977a0d (diff)
downloadHyprland-039a97adc8048f7d7ffbcc9f822b3cafdc50479c.tar.gz
Hyprland-039a97adc8048f7d7ffbcc9f822b3cafdc50479c.zip
Diffstat (limited to 'src/debug/CrashReporter.cpp')
-rw-r--r--src/debug/CrashReporter.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/debug/CrashReporter.cpp b/src/debug/CrashReporter.cpp
index 713f91df..d553b7b0 100644
--- a/src/debug/CrashReporter.cpp
+++ b/src/debug/CrashReporter.cpp
@@ -46,6 +46,8 @@ void CrashReporter::createAndSaveCrash(int sig) {
finalCrashReport += getFormat("Hyprland received signal %d (%s)\n\n", sig, strsignal(sig));
+ finalCrashReport += getFormat("Version: %s\n\n", GIT_COMMIT_HASH);
+
if (!g_pPluginSystem->getAllPlugins().empty()) {
finalCrashReport += "Hyprland seems to be running with plugins. This crash might not be Hyprland's fault.\nPlugins:\n";
@@ -127,18 +129,32 @@ void CrashReporter::createAndSaveCrash(int sig) {
finalCrashReport += execAndGet(("cat \"" + Debug::logFile + "\" | tail -n 50").c_str());
const auto HOME = getenv("HOME");
+ const auto CACHE_HOME = getenv("XDG_CACHE_HOME");
if (!HOME)
return;
- if (!std::filesystem::exists(std::string(HOME) + "/.hyprland")) {
- std::filesystem::create_directory(std::string(HOME) + "/.hyprland");
- std::filesystem::permissions(std::string(HOME) + "/.hyprland", std::filesystem::perms::all, std::filesystem::perm_options::replace);
- }
+ std::ofstream ofs;
+ if (!CACHE_HOME) {
+ if (!std::filesystem::exists(std::string(HOME) + "/.hyprland")) {
+ std::filesystem::create_directory(std::string(HOME) + "/.hyprland");
+ std::filesystem::permissions(std::string(HOME) + "/.hyprland", std::filesystem::perms::all, std::filesystem::perm_options::replace);
+ }
- std::ofstream ofs(std::string(HOME) + "/.hyprland/hyprlandCrashReport" + std::to_string(PID) + ".txt", std::ios::trunc);
+ ofs.open(std::string(HOME) + "/.hyprland/hyprlandCrashReport" + std::to_string(PID) + ".txt", std::ios::trunc);
+
+ } else if (CACHE_HOME) {
+ if (!std::filesystem::exists(std::string(CACHE_HOME) + "/hyprland")) {
+ std::filesystem::create_directory(std::string(CACHE_HOME) + "/hyprland");
+ std::filesystem::permissions(std::string(CACHE_HOME) + "/hyprland", std::filesystem::perms::all, std::filesystem::perm_options::replace);
+ }
+
+ ofs.open(std::string(CACHE_HOME) + "/hyprland/hyprlandCrashReport" + std::to_string(PID) + ".txt", std::ios::trunc);
+ } else {
+ return;
+ }
ofs << finalCrashReport;
ofs.close();
-} \ No newline at end of file
+}