diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2023-11-24 22:17:15 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2023-11-24 22:17:15 +0400 |
| commit | c95e4a738f998eedec7da10fec18be40f2d38d4a (patch) | |
| tree | 1ed948e31d2d2fe0efa50940b4981c1389f13597 /src/main.rs | |
| parent | d6b8310edb895fd0c774b7ab22710b0dd709b59c (diff) | |
| download | niri-c95e4a738f998eedec7da10fec18be40f2d38d4a.tar.gz niri-c95e4a738f998eedec7da10fec18be40f2d38d4a.tar.bz2 niri-c95e4a738f998eedec7da10fec18be40f2d38d4a.zip | |
Remove {WAYLAND_,}DISPLAY from environment if running as a service
Notably, running the GNOME Xorg session followed by niri results in a
leftover DISPLAY.
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 14 |
1 files changed, 14 insertions, 0 deletions
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(); |
