1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
Avoid various systemd dependencies
--- resources/niri.desktop.orig 2023-11-26 12:51:13 UTC
+++ resources/niri.desktop
@@ -1,6 +1,6 @@ Comment=A scrollable-tiling Wayland compositor
[Desktop Entry]
Name=Niri
Comment=A scrollable-tiling Wayland compositor
-Exec=niri-session
+Exec=niri
Type=Application
DesktopNames=niri
--- src/main.rs.orig 2024-02-17 03:47:06 UTC
+++ src/main.rs
@@ -37,7 +37,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
REMOVE_ENV_RUST_LIB_BACKTRACE.store(true, Ordering::Relaxed);
}
- let is_systemd_service = env::var_os("NOTIFY_SOCKET").is_some();
+ let is_systemd_service = env::var_os("DBUS_SESSION_BUS_ADDRESS").is_some();
let directives = env::var("RUST_LOG").unwrap_or_else(|_| "niri=debug".to_owned());
let env_filter = EnvFilter::builder().parse_lossy(directives);
@@ -46,20 +46,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_env_filter(env_filter)
.init();
- 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();
@@ -175,6 +161,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
info!("IPC listening on: {}", ipc.socket_path.to_string_lossy());
}
+ // Advise xdg-desktop-portal which *-portals.conf to load
+ env::set_var("XDG_CURRENT_DESKTOP", "niri");
+ // Mimic wlroots, used by https://github.com/qt/qtbase/commit/4b4870a12cd9
+ env::set_var("XDG_SESSION_TYPE", "wayland");
+
if is_systemd_service {
// We're starting as a systemd service. Export our variables.
import_env_to_systemd();
@@ -235,14 +226,13 @@ fn import_env_to_systemd() {
}
fn import_env_to_systemd() {
- let variables = ["WAYLAND_DISPLAY", niri_ipc::SOCKET_PATH_ENV].join(" ");
+ let variables = ["WAYLAND_DISPLAY", "XDG_CURRENT_DESKTOP", niri_ipc::SOCKET_PATH_ENV].join(" ");
let rv = Command::new("/bin/sh")
.args([
"-c",
&format!(
- "systemctl --user import-environment {variables} && \
- hash dbus-update-activation-environment 2>/dev/null && \
+ "hash dbus-update-activation-environment 2>/dev/null && \
dbus-update-activation-environment {variables}"
),
])
--- src/niri.rs.orig 2023-11-26 12:51:13 UTC
+++ src/niri.rs
@@ -743,9 +743,9 @@ impl Niri {
// logind-zbus has a wrong signature for this method, so do it manually.
// https://gitlab.com/flukejones/logind-zbus/-/merge_requests/5
let message = conn.call_method(
- Some("org.freedesktop.login1"),
- "/org/freedesktop/login1",
- Some("org.freedesktop.login1.Manager"),
+ Some("org.freedesktop.ConsoleKit"),
+ "/org/freedesktop/ConsoleKit/Manager",
+ Some("org.freedesktop.ConsoleKit.Manager"),
"Inhibit",
&("handle-power-key", "niri", "Power key handling", "block"),
)?;
|