From 00a01ba7f667eb5d516bdf18d12fca139e5b3eb8 Mon Sep 17 00:00:00 2001 From: shiro Date: Mon, 26 Feb 2024 11:12:17 +0900 Subject: [PATCH] Handle newline in X11 env check --- src/platform/mod.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/platform/mod.rs b/src/platform/mod.rs index 66ee7af..7465942 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -6,7 +6,6 @@ pub enum Platform { Unknown, } - pub fn get_platform() -> Platform { if platform_is_hyprland() { return Platform::Hyprland; @@ -29,7 +28,10 @@ fn platform_is_x11() -> bool { Command::new("printenv") .arg("XDG_SESSION_TYPE") .output() - .map(|info| info.status.success() && String::from_utf8_lossy(&info.stdout) == "x11") + .map(|info| { + info.status.success() + && String::from_utf8_lossy(&info.stdout).replace("\n", "") == "x11" + }) .unwrap_or(false) } @@ -45,4 +47,5 @@ fn platform_is_x11() -> bool { // https://unix.stackexchange.com/questions/706477/is-there-a-way-to-get-list-of-windows-on-kde-wayland // for gnome -// https://github.com/ActivityWatch/aw-watcher-window/pull/46/files \ No newline at end of file +// https://github.com/ActivityWatch/aw-watcher-window/pull/46/files +