Set XDG_CURRENT_DESKTOP and XDG_SESSION_TYPE from niri itself
Browse files at this commit9f1b4ee2996bc75ba521e9d80f001c98e379b231Parent: f0a5e9c2 changed files +12 -7
- resources/niri-session +0 -6
- src/main.rs +12 -1
resources/niri-sessionmodified+0 -6
| @@ -20,12 +20,6 @@ fi | |||
| 20 | # Reset failed state of all user units. | 20 | # Reset failed state of all user units. |
| 21 | systemctl --user reset-failed | 21 | systemctl --user reset-failed |
| 22 | 22 | ||
| 23 | -# Set the current desktop for xdg-desktop-portal. | ||
| 24 | -export XDG_CURRENT_DESKTOP=niri | ||
| 25 | - | ||
| 26 | -# Ensure the session type is set to Wayland for xdg-autostart apps. | ||
| 27 | -export XDG_SESSION_TYPE=wayland | ||
| 28 | - | ||
| 29 | # Import the login manager environment. | 23 | # Import the login manager environment. |
| 30 | systemctl --user import-environment | 24 | systemctl --user import-environment |
| 31 | 25 | ||
src/main.rsmodified+12 -1
| @@ -61,6 +61,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { | |||
| 61 | debug!("running as a session but WAYLAND_DISPLAY is set, removing it"); | 61 | debug!("running as a session but WAYLAND_DISPLAY is set, removing it"); |
| 62 | env::remove_var("WAYLAND_DISPLAY"); | 62 | env::remove_var("WAYLAND_DISPLAY"); |
| 63 | } | 63 | } |
| 64 | + | ||
| 65 | + // Set the current desktop for xdg-desktop-portal. | ||
| 66 | + env::set_var("XDG_CURRENT_DESKTOP", "niri"); | ||
| 67 | + // Ensure the session type is set to Wayland for xdg-autostart and Qt apps. | ||
| 68 | + env::set_var("XDG_SESSION_TYPE", "wayland"); | ||
| 64 | } | 69 | } |
| 65 | 70 | ||
| 66 | let _client = tracy_client::Client::start(); | 71 | let _client = tracy_client::Client::start(); |
| @@ -236,7 +241,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { | |||
| 236 | } | 241 | } |
| 237 | 242 | ||
| 238 | fn import_environment() { | 243 | fn import_environment() { |
| 239 | - let variables = ["WAYLAND_DISPLAY", niri_ipc::SOCKET_PATH_ENV].join(" "); | 244 | + let variables = [ |
| 245 | + "WAYLAND_DISPLAY", | ||
| 246 | + "XDG_CURRENT_DESKTOP", | ||
| 247 | + "XDG_SESSION_TYPE", | ||
| 248 | + niri_ipc::SOCKET_PATH_ENV, | ||
| 249 | + ] | ||
| 250 | + .join(" "); | ||
| 240 | 251 | ||
| 241 | let rv = Command::new("/bin/sh") | 252 | let rv = Command::new("/bin/sh") |
| 242 | .args([ | 253 | .args([ |