From aa96f01bf850761bf022364c36cada0f3e14a776 Mon Sep 17 00:00:00 2001 From: phideg Date: Mon, 3 Jan 2022 21:18:40 +0100 Subject: [PATCH] core dump happens if environment variable XDG_CURRENT_DESKTOP is not set. fixes #7 --- tuxedo-touchpad-switch.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tuxedo-touchpad-switch.cpp b/tuxedo-touchpad-switch.cpp index 4926181..ce1f96a 100644 --- a/tuxedo-touchpad-switch.cpp +++ b/tuxedo-touchpad-switch.cpp @@ -96,7 +96,11 @@ int main() { } char *xdg_current_desktop = getenv("XDG_CURRENT_DESKTOP"); - if (strstr(xdg_current_desktop, "GNOME")) { + if (!xdg_current_desktop) { + cout << "Your desktop environment could not be determined. Maybe running as root?" << endl; + gracefull_exit(SIGTERM); + } + else if (strstr(xdg_current_desktop, "GNOME")) { setup_gnome(lockfile); } else if (strstr(xdg_current_desktop, "KDE")) {