Remove {WAYLAND_,}DISPLAY from environment if running as a service
Browse files at this commitc95e4a738f998eedec7da10fec18be40f2d38d4aParent: d6b83101 changed file +14 -0
- src/main.rs +14 -0
src/main.rsmodified+14 -0
| @@ -79,6 +79,20 @@ fn main() { | ||
| 79 | 79 | git_version!(fallback = "unknown commit"), |
| 80 | 80 | ); |
| 81 | 81 | |
| 82 | + if is_systemd_service { | |
| 83 | + // If we're starting as a systemd service, assume that the intention is to start on a TTY. | |
| 84 | + // Remove DISPLAY or WAYLAND_DISPLAY from our environment if they are set, since they will | |
| 85 | + // cause the winit backend to be selected instead. | |
| 86 | + if env::var_os("DISPLAY").is_some() { | |
| 87 | + debug!("we're running as a systemd service but DISPLAY is set, removing it"); | |
| 88 | + env::remove_var("DISPLAY"); | |
| 89 | + } | |
| 90 | + if env::var_os("WAYLAND_DISPLAY").is_some() { | |
| 91 | + debug!("we're running as a systemd service but WAYLAND_DISPLAY is set, removing it"); | |
| 92 | + env::remove_var("WAYLAND_DISPLAY"); | |
| 93 | + } | |
| 94 | + } | |
| 95 | + | |
| 82 | 96 | let cli = Cli::parse(); |
| 83 | 97 | |
| 84 | 98 | let _client = tracy_client::Client::start(); |