Initial commit

This commit is contained in:
2025-03-19 15:32:04 +01:00
commit 1c2f8b08d3
8 changed files with 542 additions and 0 deletions

73
src/main.rs Normal file
View File

@@ -0,0 +1,73 @@
// https://specifications.freedesktop.org/thumbnail-spec/latest/
use dbus::blocking::{BlockingSender, Connection, Proxy};
use dbus::Message;
use std::path::PathBuf;
use std::time::Duration;
fn main() {
let connection: Connection = Connection::new_session().unwrap();
let thumbnailers = list_thumbnailers(&connection);
dbg!(&thumbnailers);
}
fn thumbnailer_proxy(connection: &Connection) -> Proxy<&Connection> {
connection.with_proxy(
"org.freedesktop.thumbnails.Thumbnailer1",
"/org/freedesktop/thumbnails/Thumbnailer1",
Duration::from_millis(5000),
)
}
fn cache_proxy(connection: &Connection) -> Proxy<&Connection> {
connection.with_proxy(
"org.freedesktop.thumbnails.Cache1",
"/org/freedesktop/thumbnails/Cache1",
Duration::from_millis(5000),
)
}
fn manager_proxy(connection: &Connection) -> Proxy<&Connection> {
connection.with_proxy(
"org.freedesktop.thumbnails.Manager1",
"/org/freedesktop/thumbnails/Manager1",
Duration::from_millis(5000),
)
}
// fn list_thumbnailers(connection: &Connection) -> Vec<String> {
// let (names,): (Vec<String>,) = proxy
// .method_call(
// "org.freedesktop.DBus.Properties",
// "Get",
// ("org.freedesktop.thumbnails.Thumbnailer1", "Thumbnailers"),
// )
// .unwrap();
// // names
// vec![]
// }
fn queue_thumbnails(connection: &Connection, paths: Vec<PathBuf>) {
let mut proxy = thumbnailer_proxy(connection);
let (handle,): (u32,) = proxy.method_call(
"org.freedesktop.thumbnails.Thumbnailer1",
"Queue",
(
paths.iter().map(|p| p.to_string_lossy().to_string()).collect::<Vec<String>>(),
vec![], // mime types
"normal", // flavor
"", // scheduler
0, // handle_to_unqueue
),
).unwrap();
// proxy.send_with_reply_and_block(
// Message::new_method_call(
// "org.freedesktop.thumbnails.Thumbnailer1",
// "/org/freedesktop/thumbnails/Thumbnailer1",
// "org.freedesktop.thumbnails.Thumbnailer1",
// "Queue",
// ).unwrap();
// , timeout)
}