From 58e8b2bda688ae37f72869657948dcdd70ff5baf Mon Sep 17 00:00:00 2001
From: Maxim Naumov <overlordin777@gmail.com>
Date: Thu, 9 Sep 2021 00:26:05 +0400
Subject: [PATCH] Added set command to the config.

---
 lib/background.rs | 6 +++++-
 lib/config/mod.rs | 6 ++++++
 lib/result.rs     | 2 +-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/lib/background.rs b/lib/background.rs
index 11749e9..7a973ac 100644
--- a/lib/background.rs
+++ b/lib/background.rs
@@ -41,7 +41,11 @@ pub fn process_image_url(image_url: String) -> MBGResult<()> {
 
 pub fn set_wallpaper(path: &str) {
     debug!("Setting background");
-    let out = Command::new("feh").arg("--bg-fill").arg(path).output();
+    let config = Config::get_props();
+    let out = Command::new("sh")
+        .arg("-c")
+        .arg(config.set_command.replace(r"{}", path))
+        .output();
     if let Err(set_error) = out {
         error!("Can't set background: {}", set_error.to_string());
     }
diff --git a/lib/config/mod.rs b/lib/config/mod.rs
index 97279bb..92f185c 100644
--- a/lib/config/mod.rs
+++ b/lib/config/mod.rs
@@ -12,6 +12,8 @@ pub mod logger;
 pub struct Config {
     #[serde(default)]
     pub blender: Vec<u8>,
+    #[serde(default = "set_command_default")]
+    pub set_command: String,
     #[serde(default = "reset_command_default")]
     pub reset_command: String,
     #[serde(default)]
@@ -24,6 +26,10 @@ pub fn reset_command_default() -> String {
     String::from("nitrogen --restore")
 }
 
+pub fn set_command_default() -> String {
+    String::from(r#"nitrogen --set-auto "{}""#)
+}
+
 impl Config {
     fn new() -> Self {
         Config {
diff --git a/lib/result.rs b/lib/result.rs
index d18543a..25af0a9 100644
--- a/lib/result.rs
+++ b/lib/result.rs
@@ -54,4 +54,4 @@ impl From<image::error::ImageError> for MBGError {
     fn from(err: image::error::ImageError) -> Self {
         MBGError::ImageError(err.to_string())
     }
-}
\ No newline at end of file
+}
-- 
GitLab