mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-22 02:01:55 +07:00
Make zbus optional under "dbus" feature
This commit is contained in:
+8
-6
@@ -8,8 +8,8 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
anyhow = { version = "1.0.75" }
|
||||
async-channel = "1.9.0"
|
||||
async-io = "1.13.0"
|
||||
async-channel = { version = "1.9.0", optional = true }
|
||||
async-io = { version = "1.13.0", optional = true }
|
||||
bitflags = "2.4.0"
|
||||
clap = { version = "4.4.6", features = ["derive"] }
|
||||
directories = "5.0.1"
|
||||
@@ -17,7 +17,7 @@ image = { version = "0.24.7", default-features = false, features = ["png"] }
|
||||
keyframe = { version = "1.1.1", default-features = false }
|
||||
knuffel = "3.2.0"
|
||||
libc = "0.2.149"
|
||||
logind-zbus = "3.1.2"
|
||||
logind-zbus = { version = "3.1.2", optional = true }
|
||||
log = { version = "0.4.20", features = ["max_level_trace", "release_max_level_debug"] }
|
||||
miette = "5.10.0"
|
||||
nix = { version = "0.27.1", default-features = false, features = ["time"] }
|
||||
@@ -31,7 +31,7 @@ tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
|
||||
tracing = { version = "0.1.37", features = ["max_level_trace", "release_max_level_debug"] }
|
||||
tracy-client = { version = "0.16.3", default-features = false }
|
||||
xcursor = "0.3.4"
|
||||
zbus = { version = "3.14.1" }
|
||||
zbus = { version = "3.14.1", optional = true }
|
||||
|
||||
[dependencies.smithay]
|
||||
git = "https://github.com/Smithay/smithay.git"
|
||||
@@ -62,9 +62,11 @@ proptest = "1.3.1"
|
||||
proptest-derive = "0.4.0"
|
||||
|
||||
[features]
|
||||
default = ["xdp-gnome-screencast"]
|
||||
default = ["dbus", "xdp-gnome-screencast"]
|
||||
# Enables DBus support (required for xdp-gnome and power button inhibiting).
|
||||
dbus = ["zbus", "logind-zbus", "async-channel", "async-io"]
|
||||
# Enables screencasting support through xdg-desktop-portal-gnome.
|
||||
xdp-gnome-screencast = ["pipewire"]
|
||||
xdp-gnome-screencast = ["dbus", "pipewire"]
|
||||
# Enables the Tracy profiler instrumentation.
|
||||
profile-with-tracy = ["profiling/profile-with-tracy", "tracy-client/default"]
|
||||
|
||||
|
||||
@@ -84,6 +84,7 @@ impl Backend {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "dbus"), allow(unused))]
|
||||
pub fn connectors(&self) -> Arc<Mutex<HashMap<String, Output>>> {
|
||||
match self {
|
||||
Backend::Tty(tty) => tty.connectors(),
|
||||
|
||||
@@ -924,6 +924,7 @@ impl Tty {
|
||||
}
|
||||
|
||||
pub fn suspend(&self) {
|
||||
#[cfg(feature = "dbus")]
|
||||
if let Err(err) = suspend() {
|
||||
warn!("error suspending: {err:?}");
|
||||
}
|
||||
@@ -1026,6 +1027,7 @@ fn refresh_interval(mode: DrmMode) -> Duration {
|
||||
Duration::from_nanos(refresh_interval)
|
||||
}
|
||||
|
||||
#[cfg(feature = "dbus")]
|
||||
fn suspend() -> anyhow::Result<()> {
|
||||
let conn = zbus::blocking::Connection::system().context("error connecting to system bus")?;
|
||||
let manager = logind_zbus::manager::ManagerProxyBlocking::new(&conn)
|
||||
|
||||
+4
-3
@@ -5,6 +5,7 @@ mod animation;
|
||||
mod backend;
|
||||
mod config;
|
||||
mod cursor;
|
||||
#[cfg(feature = "dbus")]
|
||||
mod dbus;
|
||||
mod frame_clock;
|
||||
mod handlers;
|
||||
@@ -37,8 +38,6 @@ use tracing_subscriber::EnvFilter;
|
||||
use utils::spawn;
|
||||
use watcher::Watcher;
|
||||
|
||||
use crate::dbus::DBusServers;
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(author, version, about, long_about = None)]
|
||||
struct Cli {
|
||||
@@ -104,12 +103,14 @@ fn main() {
|
||||
import_env_to_systemd();
|
||||
|
||||
// Inhibit power key handling so we can suspend on it.
|
||||
#[cfg(feature = "dbus")]
|
||||
if let Err(err) = state.niri.inhibit_power_key() {
|
||||
warn!("error inhibiting power key: {err:?}");
|
||||
}
|
||||
}
|
||||
|
||||
DBusServers::start(&mut state, is_systemd_service);
|
||||
#[cfg(feature = "dbus")]
|
||||
dbus::DBusServers::start(&mut state, is_systemd_service);
|
||||
|
||||
// Notify systemd we're ready.
|
||||
if let Err(err) = sd_notify::notify(true, &[NotifyState::Ready]) {
|
||||
|
||||
+14
-4
@@ -1,5 +1,4 @@
|
||||
use std::cell::RefCell;
|
||||
use std::cmp::max;
|
||||
use std::collections::HashMap;
|
||||
use std::ffi::OsString;
|
||||
use std::path::PathBuf;
|
||||
@@ -15,7 +14,6 @@ use smithay::backend::renderer::element::surface::{
|
||||
render_elements_from_surface_tree, WaylandSurfaceRenderElement,
|
||||
};
|
||||
use smithay::backend::renderer::element::texture::TextureRenderElement;
|
||||
use smithay::backend::renderer::element::utils::{Relocate, RelocateRenderElement};
|
||||
use smithay::backend::renderer::element::{
|
||||
default_primary_scanout_output_compare, render_elements, AsRenderElements, Kind, RenderElement,
|
||||
RenderElementStates,
|
||||
@@ -74,10 +72,10 @@ use smithay::wayland::virtual_keyboard::VirtualKeyboardManagerState;
|
||||
use crate::backend::{Backend, Tty, Winit};
|
||||
use crate::config::Config;
|
||||
use crate::cursor::Cursor;
|
||||
#[cfg(feature = "dbus")]
|
||||
use crate::dbus::gnome_shell_screenshot::{NiriToScreenshot, ScreenshotToNiri};
|
||||
#[cfg(feature = "xdp-gnome-screencast")]
|
||||
use crate::dbus::mutter_screen_cast::{self, ScreenCastToNiri};
|
||||
use crate::dbus::DBusServers;
|
||||
use crate::frame_clock::FrameClock;
|
||||
use crate::layout::{output_size, Layout, MonitorRenderElement};
|
||||
use crate::pw_utils::{Cast, PipeWire};
|
||||
@@ -134,7 +132,9 @@ pub struct Niri {
|
||||
pub cursor_image: CursorImageStatus,
|
||||
pub dnd_icon: Option<WlSurface>,
|
||||
|
||||
pub dbus: Option<DBusServers>,
|
||||
#[cfg(feature = "dbus")]
|
||||
pub dbus: Option<crate::dbus::DBusServers>,
|
||||
#[cfg(feature = "dbus")]
|
||||
pub inhibit_power_key_fd: Option<zbus::zvariant::OwnedFd>,
|
||||
|
||||
// Casts are dropped before PipeWire to prevent a double-free (yay).
|
||||
@@ -352,6 +352,7 @@ impl State {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "dbus")]
|
||||
pub fn on_screen_shot_msg(
|
||||
&mut self,
|
||||
to_screenshot: &async_channel::Sender<NiriToScreenshot>,
|
||||
@@ -533,13 +534,17 @@ impl Niri {
|
||||
cursor_image: CursorImageStatus::default_named(),
|
||||
dnd_icon: None,
|
||||
|
||||
#[cfg(feature = "dbus")]
|
||||
dbus: None,
|
||||
#[cfg(feature = "dbus")]
|
||||
inhibit_power_key_fd: None,
|
||||
|
||||
pipewire,
|
||||
casts: vec![],
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "dbus")]
|
||||
pub fn inhibit_power_key(&mut self) -> anyhow::Result<()> {
|
||||
let conn = zbus::blocking::ConnectionBuilder::system()?.build()?;
|
||||
|
||||
@@ -1520,12 +1525,17 @@ impl Niri {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "dbus")]
|
||||
pub fn screenshot_all_outputs(
|
||||
&mut self,
|
||||
renderer: &mut GlesRenderer,
|
||||
include_pointer: bool,
|
||||
on_done: impl FnOnce(PathBuf) + Send + 'static,
|
||||
) -> anyhow::Result<()> {
|
||||
use std::cmp::max;
|
||||
|
||||
use smithay::backend::renderer::element::utils::{Relocate, RelocateRenderElement};
|
||||
|
||||
let _span = tracy_client::span!("Niri::screenshot_all_outputs");
|
||||
|
||||
let mut elements = vec![];
|
||||
|
||||
Reference in New Issue
Block a user