libmacchina
libmacchina copied to clipboard
X11 window manager is not detected when XDG_SESSION_TYPE is incorrect
I was just setting up a testing setup to try and fix #9.
I am on hyprland.
I have a Xephyr x session opened as display :3.
I ran DISPLAY=:3 awesome to run the wm.
Then I ran DISPLAY=:3 env -u WAYLAND_DISPLAY alacritty to get a terminal in the x session
but when I ran my fetch no wm was detected.
In the libmacchina code when deciding if to check for X11 or Wayland the XDG_SESSION_TYPE env variable is used.
This was still set to wayland so it ran detect_wayland_window_manager() which obviously failed on x11.
This could be prevented by doing detect_wayland_window_manager().or_else(|_| detect_xorg_window_manager()).
But that sounds like a very lazy and incomplete solution.
I just tried to run a regular x session with startx but XDG_SESSION_TYPE was now set to tty creating the same problem.
I don't think we should be relying on XDG_SESSION_TYPE.
elkowar/eww uses this to detect wayland
fn detect_wayland() -> bool {
let session_type = std::env::var("XDG_SESSION_TYPE").unwrap_or_default();
let wayland_display = std::env::var("WAYLAND_DISPLAY").unwrap_or_default();
session_type.contains("wayland") || (!wayland_display.is_empty() && !session_type.contains("x11"))
}
don't know how to work with github did not mean to do that