diff --git a/Cargo.toml b/Cargo.toml index 54598f5d685a4e146efe1c9371fc83bbfc583468..69e0f47050de9c760b0e6c8f9c00b4273b9c7a8a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,5 +45,6 @@ features = [ [dependencies.x11rb] # Used to interact with X11. version = "0.4.1" features = [ - "all-extensions" + "xinerama", + "xproto" ] \ No newline at end of file diff --git a/lib/background.rs b/lib/background.rs index 3318ca6fbc3d28ae4f9630ccd75234e88a472366..fa7cbe3456522c834087149959cb538c2d6258b8 100644 --- a/lib/background.rs +++ b/lib/background.rs @@ -5,6 +5,8 @@ use dbus::Message; use crate::img_processors::process_image; use crate::result::MBGResult; +use crate::display::update_bg; +use crate::config::Config; pub fn reset_background_handler(_: (), _: &Connection, message: &Message) -> bool { @@ -19,7 +21,8 @@ pub fn reset_background_handler(_: (), _: &Connection, message: &Message) -> boo pub fn nitrogen_restore() { info!("Reset BG"); - let out = Command::new("nitrogen").arg("--restore").output(); + let config = Config::get_props(); + let out = Command::new("sh").arg("-c").arg(config.reset_command.as_str()).output(); if let Err(restore_error) = out { error!("Can't restore background: {}", restore_error.to_string()); } diff --git a/lib/config/mod.rs b/lib/config/mod.rs index b1cde04cc79bc99da9660cab7565d841cf93a4fb..97279bbf3f47556c2b39577a2dc99bcd47924ab7 100644 --- a/lib/config/mod.rs +++ b/lib/config/mod.rs @@ -12,15 +12,22 @@ pub mod logger; pub struct Config { #[serde(default)] pub blender: Vec<u8>, + #[serde(default = "reset_command_default")] + pub reset_command: String, #[serde(default)] pub logger: logger::LoggerConfig, #[serde(default)] pub processors: Vec<image_processors::ProcessorParams>, } +pub fn reset_command_default() -> String { + String::from("nitrogen --restore") +} + impl Config { fn new() -> Self { Config { + reset_command: reset_command_default(), ..Default::default() } } @@ -63,7 +70,7 @@ impl Config { let mut config_path = home_dir.unwrap(); config_path.push(".mbg.toml"); let mut conf_file = File::create(config_path)?; - let mut default_conf = Self::default(); + let mut default_conf = Self::new(); default_conf .processors .push(image_processors::ProcessorParams::default());