Compare commits
2 Commits
cc45f5cf59
...
a30333b77e
| Author | SHA1 | Date | |
|---|---|---|---|
| a30333b77e | |||
| 56dd495f83 |
@ -5,6 +5,7 @@ pub enum WallpaperHandler {
|
|||||||
Feh,
|
Feh,
|
||||||
Plasma,
|
Plasma,
|
||||||
Gnome,
|
Gnome,
|
||||||
|
Hyprpaper,
|
||||||
Error,
|
Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14,6 +15,7 @@ impl WallpaperHandler {
|
|||||||
"feh" => WallpaperHandler::Feh,
|
"feh" => WallpaperHandler::Feh,
|
||||||
"plasma" => WallpaperHandler::Plasma,
|
"plasma" => WallpaperHandler::Plasma,
|
||||||
"gnome" => WallpaperHandler::Gnome,
|
"gnome" => WallpaperHandler::Gnome,
|
||||||
|
"hyprpaper" => WallpaperHandler::Hyprpaper,
|
||||||
_ => WallpaperHandler::Error,
|
_ => WallpaperHandler::Error,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,17 @@
|
|||||||
|
use std::fmt::Write as _;
|
||||||
|
use crate::lib::ipc;
|
||||||
use crate::Wallpapers;
|
use crate::Wallpapers;
|
||||||
|
|
||||||
use std::process::Command;
|
|
||||||
|
|
||||||
pub fn change_wallpapers(wallpapers: &Wallpapers) {
|
pub fn change_wallpapers(wallpapers: &Wallpapers) {
|
||||||
let mut command = Command::new("/usr/bin/feh");
|
let ipc = ipc::IPC::new(String::from("/run/user/1000/hypr/9958d297641b5c84dcff93f9039d80a5ad37ab00_1751412591_2000702590/.hyprpaper.sock"));
|
||||||
command.arg("--no-fehbg").arg("--bg-fill");
|
|
||||||
|
|
||||||
for monitor in wallpapers.config.monitors.monitors.iter() {
|
for monitor in wallpapers.config.monitors.monitors.iter() {
|
||||||
command.arg(wallpapers.random_selection(&monitor.ratio).to_string());
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = command.output();
|
// println!("{}", ipc.write(String::from("")))
|
||||||
match result {
|
|
||||||
Ok(_) => {}
|
|
||||||
Err(e) => println!("{}", e),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
26
src/lib/ipc.rs
Normal file
26
src/lib/ipc.rs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
1
src/lib/mod.rs
Normal file
1
src/lib/mod.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
pub mod ipc;
|
||||||
@ -5,6 +5,7 @@ mod files;
|
|||||||
use enums::WallpaperHandler;
|
use enums::WallpaperHandler;
|
||||||
use files::*;
|
use files::*;
|
||||||
mod handlers;
|
mod handlers;
|
||||||
|
mod lib;
|
||||||
|
|
||||||
use untildify::untildify;
|
use untildify::untildify;
|
||||||
|
|
||||||
@ -32,6 +33,9 @@ fn main() {
|
|||||||
WallpaperHandler::Gnome => {
|
WallpaperHandler::Gnome => {
|
||||||
handlers::gnome::change_wallpapers(&wallpapers);
|
handlers::gnome::change_wallpapers(&wallpapers);
|
||||||
}
|
}
|
||||||
|
WallpaperHandler::Hyprpaper => {
|
||||||
|
handlers::hyprpaper::change_wallpapers(&wallpapers);
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
println!("Error: Unknown wallpaper engine");
|
println!("Error: Unknown wallpaper engine");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user