improve image lookup

This commit is contained in:
Alexander Mohr 2025-04-24 20:16:23 +02:00
parent e18684e8a4
commit 1cf6fa5f13
2 changed files with 5 additions and 6 deletions

View file

@ -786,10 +786,8 @@ fn create_menu_row<T: Clone + 'static>(
fn lookup_icon<T: Clone>(menu_item: &MenuItem<T>, config: &Config) -> Option<Image> {
if let Some(image_path) = &menu_item.icon_path {
let img_regex = Regex::new(&format!(r"(?i).*{}", known_image_extension_regex_pattern()));
let image = if image_path.starts_with("/") {
Image::from_file(image_path)
} else if img_regex.unwrap().is_match(image_path) {
let img_regex = Regex::new(&format!(r"((?i).*{})|(^/.*)", known_image_extension_regex_pattern()));
let image = if img_regex.unwrap().is_match(image_path) {
if let Ok(img) = desktop::fetch_icon_from_common_dirs(&image_path) {
Image::from_file(img)
} else {

View file

@ -128,13 +128,14 @@ impl<T: Clone> DRunProvider<T> {
.icon
.as_ref()
.map(|s| s.content.clone())
.or(icon.clone());
.or(icon.clone())
.unwrap_or("application-x-executable".to_string());
log::debug!("sub, action_name={action_name:?}, action_icon={action_icon:?}");
let sub_entry = MenuItem {
label: action_name,
icon_path: action_icon,
icon_path: Some(action_icon),
action: action.exec.clone(),
sub_elements: Vec::default(),
working_dir: working_dir.clone(),