Skip to content

Commit

Permalink
chore: run cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
InioX committed Oct 26, 2024
1 parent 3b9c1db commit d28336a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
5 changes: 1 addition & 4 deletions src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ pub fn set_wallpaper(source: &Source, wallpaper_cfg: wallpaper::Wallpaper) -> Re
#[cfg(target_os = "macos")]
wallpaper::macos::set(&path)?;
#[cfg(any(target_os = "linux", target_os = "netbsd"))]
wallpaper::unix::set(
path,
wallpaper_cfg
)?;
wallpaper::unix::set(path, wallpaper_cfg)?;
Ok(())
}
2 changes: 1 addition & 1 deletion src/util/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use color_eyre::{Help, Report};
use serde::{Deserialize, Serialize};

use super::arguments::Cli;
use crate::Template;
use crate::wallpaper::Wallpaper;
use crate::Template;

#[derive(Serialize, Deserialize, Debug)]
pub struct Config {
Expand Down
26 changes: 14 additions & 12 deletions src/wallpaper/unix.rs
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
use color_eyre::Report;
use std::process::{Command, Stdio};
use crate::wallpaper::Wallpaper;
use color_eyre::Report;
use execute::Execute;
use std::process::{Command, Stdio};

#[cfg(any(target_os = "linux", target_os = "netbsd"))]
pub fn set(
path: &String,
Wallpaper { pre_hook, command, arguments, .. }: Wallpaper,
Wallpaper {
pre_hook,
command,
arguments,
..
}: Wallpaper,
) -> Result<(), Report> {
info!("Setting wallpaper...");

if let Some(hook) = pre_hook {
spawn_hook(hook)?
spawn_hook(hook)?
}

let mut binding = Command::new(&command);
let cmd = binding
.stdout(Stdio::null())
.stderr(Stdio::null());
let cmd = binding.stdout(Stdio::null()).stderr(Stdio::null());

if let Some(args) = arguments {
cmd.args(args);
cmd.args(args);
}
cmd.arg(path);


match cmd.spawn() {
Ok(_) => info!("Successfully set the wallpaper with <blue>{command}</>"),
Err(e) => {
if let std::io::ErrorKind::NotFound = e.kind() {
error!("Failed to set wallpaper, the program <red>{command}</> was not found in PATH!")
error!(
"Failed to set wallpaper, the program <red>{command}</> was not found in PATH!"
)
} else {
error!("Some error(s) occured while setting wallpaper!");
}
Expand All @@ -38,8 +42,6 @@ pub fn set(
Ok(())
}



#[cfg(any(target_os = "linux", target_os = "netbsd"))]
fn spawn_hook(hook: String) -> Result<(), Report> {
let mut command = execute::shell(&hook);
Expand Down

0 comments on commit d28336a

Please sign in to comment.