Fix crash when XDG_CURRENT_DESKTOP isn't defined

This commit is contained in:
KockaAdmiralac 2018-12-19 22:19:18 +01:00
parent 6d23c773aa
commit 6ebb92c6b9
No known key found for this signature in database
GPG Key ID: A6007A5107D8CFBD
1 changed files with 28 additions and 23 deletions

View File

@ -281,29 +281,34 @@ Oneshot::Oneshot(RGSSThreadData &threadData) :
#endif #endif
#ifdef OS_LINUX #ifdef OS_LINUX
std::string desktop(getenv("XDG_CURRENT_DESKTOP")); char const* xdg_current_desktop = getenv("XDG_CURRENT_DESKTOP");
std::transform(desktop.begin(), desktop.end(), desktop.begin(), ::tolower); if (xdg_current_desktop == NULL) {
if (desktop.find("cinnamon") != std::string::npos) { desktopEnv = "nope";
desktopEnv = "cinnamon"; } else {
gtk_init(0, 0); std::string desktop(xdg_current_desktop);
} else if ( std::transform(desktop.begin(), desktop.end(), desktop.begin(), ::tolower);
desktop.find("gnome") != std::string::npos || if (desktop.find("cinnamon") != std::string::npos) {
desktop.find("unity") != std::string::npos desktopEnv = "cinnamon";
) { gtk_init(0, 0);
desktopEnv = "gnome"; } else if (
gtk_init(0, 0); desktop.find("gnome") != std::string::npos ||
} else if (desktop.find("mate") != std::string::npos) { desktop.find("unity") != std::string::npos
desktopEnv = "mate"; ) {
gtk_init(0, 0); desktopEnv = "gnome";
} else if (desktop.find("xfce") != std::string::npos) { gtk_init(0, 0);
desktopEnv = "xfce"; } else if (desktop.find("mate") != std::string::npos) {
gtk_init(0, 0); desktopEnv = "mate";
} else if (desktop.find("kde") != std::string::npos) { gtk_init(0, 0);
desktopEnv = "kde"; } else if (desktop.find("xfce") != std::string::npos) {
} else if (desktop.find("lxde") != std::string::npos) { desktopEnv = "xfce";
desktopEnv = "lxde"; gtk_init(0, 0);
} else if (desktop.find("deepin") != std::string::npos) { } else if (desktop.find("kde") != std::string::npos) {
desktopEnv = "deepin"; desktopEnv = "kde";
} else if (desktop.find("lxde") != std::string::npos) {
desktopEnv = "lxde";
} else if (desktop.find("deepin") != std::string::npos) {
desktopEnv = "deepin";
}
} }
#endif #endif