Compare commits

...

4 Commits

Author SHA1 Message Date
636197baab Get hyprland session at runtime
All checks were successful
/ release (push) Successful in 1m29s
2025-07-02 01:01:19 -04:00
997508cedf Removed duplicate true 2025-07-02 01:01:19 -04:00
dadd07c4c6 added ipc 2025-07-02 01:01:19 -04:00
65b84198f4 Added hyprpaper support 2025-07-02 01:01:19 -04:00
8 changed files with 165 additions and 1 deletions

107
Cargo.lock generated
View File

@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo. # This file is automatically @generated by Cargo.
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3 version = 4
[[package]] [[package]]
name = "aho-corasick" name = "aho-corasick"
@ -34,6 +34,12 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "doctest-file"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aac81fa3e28d21450aa4d2ac065992ba96a1d7303efbce51a95f4fd175b67562"
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.2.12" version = "0.2.12"
@ -51,6 +57,19 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]]
name = "interprocess"
version = "2.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "894148491d817cb36b6f778017b8ac46b17408d522dd90f539d677ea938362eb"
dependencies = [
"doctest-file",
"libc",
"recvmsg",
"widestring",
"windows-sys",
]
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.153" version = "0.2.153"
@ -79,6 +98,7 @@ dependencies = [
"configparser", "configparser",
"dbus", "dbus",
"glob", "glob",
"interprocess",
"rand", "rand",
"untildify", "untildify",
] ]
@ -125,6 +145,12 @@ dependencies = [
"getrandom", "getrandom",
] ]
[[package]]
name = "recvmsg"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3edd4d5d42c92f0a659926464d4cce56b562761267ecf0f469d85b7de384175"
[[package]] [[package]]
name = "regex" name = "regex"
version = "1.10.3" version = "1.10.3"
@ -168,6 +194,12 @@ version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "widestring"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311"
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.3.9" version = "0.3.9"
@ -189,3 +221,76 @@ name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-sys"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"

View File

@ -7,5 +7,6 @@ edition = "2021"
configparser = "3.0.4" configparser = "3.0.4"
dbus = "0.9.7" dbus = "0.9.7"
glob = "0.3.1" glob = "0.3.1"
interprocess = "2.2.2"
rand = "0.8.5" rand = "0.8.5"
untildify = { git = "https://git.lovelynet.net/benjamyn/untildify.git", branch = "main" } untildify = { git = "https://git.lovelynet.net/benjamyn/untildify.git", branch = "main" }

View File

@ -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,
} }
} }

24
src/handlers/hyprpaper.rs Normal file
View File

@ -0,0 +1,24 @@
use std::fmt::Write as _;
use crate::lib::ipc;
use crate::Wallpapers;
use std::env;
pub fn change_wallpapers(wallpapers: &Wallpapers) {
let hypr_session = env::var("HYPRLAND_INSTANCE_SIGNATURE").unwrap();
let xdg_path = env::var("XDG_RUNTIME_DIR").unwrap();
let mut socket_path = String::new();
write!(&mut socket_path, "{}/hypr/{}/.hyprpaper.sock", xdg_path, hypr_session).unwrap();
let ipc = ipc::IPC::new(socket_path);
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);
}
// println!("{}", ipc.write(String::from("")))
}

View File

@ -2,3 +2,4 @@ pub mod dbus_plasma_interface;
pub mod feh; pub mod feh;
pub mod gnome; pub mod gnome;
pub mod plasma; pub mod plasma;
pub mod hyprpaper;

26
src/lib/ipc.rs Normal file
View 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
View File

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

View File

@ -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");
} }