From c95e4a738f998eedec7da10fec18be40f2d38d4a Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Fri, 24 Nov 2023 22:17:15 +0400 Subject: Remove {WAYLAND_,}DISPLAY from environment if running as a service Notably, running the GNOME Xorg session followed by niri results in a leftover DISPLAY. --- src/main.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main.rs b/src/main.rs index 5367dcf5..51773efe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -79,6 +79,20 @@ fn main() { git_version!(fallback = "unknown commit"), ); + if is_systemd_service { + // If we're starting as a systemd service, assume that the intention is to start on a TTY. + // Remove DISPLAY or WAYLAND_DISPLAY from our environment if they are set, since they will + // cause the winit backend to be selected instead. + if env::var_os("DISPLAY").is_some() { + debug!("we're running as a systemd service but DISPLAY is set, removing it"); + env::remove_var("DISPLAY"); + } + if env::var_os("WAYLAND_DISPLAY").is_some() { + debug!("we're running as a systemd service but WAYLAND_DISPLAY is set, removing it"); + env::remove_var("WAYLAND_DISPLAY"); + } + } + let cli = Cli::parse(); let _client = tracy_client::Client::start(); -- cgit