Compare commits

..

No commits in common. "a30333b77e2df1db53ef91817e5fc12a6c82a63d" and "cc45f5cf592a8504c6450b29ab48a7a49f131362" have entirely different histories.

5 changed files with 10 additions and 42 deletions

View File

@ -5,7 +5,6 @@ pub enum WallpaperHandler {
Feh,
Plasma,
Gnome,
Hyprpaper,
Error,
}
@ -15,7 +14,6 @@ impl WallpaperHandler {
"feh" => WallpaperHandler::Feh,
"plasma" => WallpaperHandler::Plasma,
"gnome" => WallpaperHandler::Gnome,
"hyprpaper" => WallpaperHandler::Hyprpaper,
_ => WallpaperHandler::Error,
}
}

View File

@ -1,17 +1,18 @@
use std::fmt::Write as _;
use crate::lib::ipc;
use crate::Wallpapers;
use std::process::Command;
pub fn change_wallpapers(wallpapers: &Wallpapers) {
let ipc = ipc::IPC::new(String::from("/run/user/1000/hypr/9958d297641b5c84dcff93f9039d80a5ad37ab00_1751412591_2000702590/.hyprpaper.sock"));
let mut command = Command::new("/usr/bin/feh");
command.arg("--no-fehbg").arg("--bg-fill");
for monitor in wallpapers.config.monitors.monitors.iter() {
let mut buf = String::new();
let x = wallpapers.random_selection(&monitor.ratio).to_string();
write!(&mut buf, "reload ,{}", x).unwrap();
ipc.clone().write(buf);
// println!("{}", buf);
command.arg(wallpapers.random_selection(&monitor.ratio).to_string());
}
// println!("{}", ipc.write(String::from("")))
let result = command.output();
match result {
Ok(_) => {}
Err(e) => println!("{}", e),
}
}

View File

@ -1,26 +0,0 @@
use std::{io::Write, os::unix::net::UnixStream};
#[derive(Clone)]
pub struct IPC {
path: String
}
impl IPC {
pub fn new(path: String) -> IPC {
IPC{ path: path}
}
pub fn write(self, data: String) -> bool {
let mut stream = UnixStream::connect(&self.path).unwrap();
let resp = stream.write_all(data.as_bytes());
match resp {
Ok(_) => return true,
Err(_) => return false,
}
}
pub fn read(self) -> String {
// let mut x = String::new();
String::from(self.path)
}
}

View File

@ -1 +0,0 @@
pub mod ipc;

View File

@ -5,7 +5,6 @@ mod files;
use enums::WallpaperHandler;
use files::*;
mod handlers;
mod lib;
use untildify::untildify;
@ -33,9 +32,6 @@ fn main() {
WallpaperHandler::Gnome => {
handlers::gnome::change_wallpapers(&wallpapers);
}
WallpaperHandler::Hyprpaper => {
handlers::hyprpaper::change_wallpapers(&wallpapers);
}
_ => {
println!("Error: Unknown wallpaper engine");
}