status-area: Add theme_path to IconUpdate

This commit is contained in:
Ian Douglas Scott 2025-11-04 10:29:58 -08:00 committed by Jacob Kauffmann
parent e7e275abf7
commit 9b979ccf74

View file

@ -4,6 +4,7 @@
use cosmic::iced::{self, Subscription};
use futures::{FutureExt, StreamExt};
use rustc_hash::FxHashMap;
use std::path::PathBuf;
use zbus::zvariant::{self, OwnedValue};
#[derive(Clone, Debug)]
@ -24,6 +25,7 @@ pub struct Icon {
pub struct IconUpdate {
pub name: Option<String>,
pub pixmap: Option<Vec<Icon>>,
pub theme_path: Option<PathBuf>,
}
impl StatusNotifierItem {
@ -96,9 +98,11 @@ impl StatusNotifierItem {
async fn icon_events(item_proxy: StatusNotifierItemProxy<'static>) -> IconUpdate {
let icon_name = item_proxy.icon_name().await;
let icon_pixmap = item_proxy.icon_pixmap().await;
let icon_theme_path = item_proxy.icon_theme_path().await.map(PathBuf::from);
IconUpdate {
name: icon_name.ok(),
pixmap: icon_pixmap.ok(),
theme_path: icon_theme_path.ok().filter(|x| !x.as_os_str().is_empty()),
}
}
@ -136,6 +140,9 @@ pub trait StatusNotifierItem {
#[zbus(property)]
fn icon_name(&self) -> zbus::Result<String>;
#[zbus(property)]
fn icon_theme_path(&self) -> zbus::Result<String>;
// https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/Icons
#[zbus(property)]
fn icon_pixmap(&self) -> zbus::Result<Vec<Icon>>;