diff --git a/Cargo.lock b/Cargo.lock index adeeaba..a0e2124 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -320,7 +320,7 @@ dependencies = [ [[package]] name = "tux-icons" -version = "0.2.0" +version = "0.2.1" dependencies = [ "dirs 5.0.1", "freedesktop-desktop-entry", diff --git a/Cargo.toml b/Cargo.toml index 19b262f..7ee4a51 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tux-icons" -version = "0.2.0" +version = "0.2.1" edition = "2021" license = "MIT" description = "A library for getting desktop icons in linux" diff --git a/README.md b/README.md index ef6c024..6bd5100 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ cargo add tux-icons Or add it manually in cargo.toml: ```toml [dependencies] -tux-icons = "0.2.0" +tux-icons = "0.2.1" ``` # Usage diff --git a/src/icon_fetcher/mod.rs b/src/icon_fetcher/mod.rs index e8c2869..cd9bc8f 100644 --- a/src/icon_fetcher/mod.rs +++ b/src/icon_fetcher/mod.rs @@ -36,13 +36,19 @@ fn get_system_icon_pack() -> String { fn get_target_path(path: impl Into) -> Option { let path: PathBuf = path.into(); + println!("Is symlink: {}", path.is_symlink()); + if !path.is_symlink() { return Some(path); } return if let Ok(link) = path.read_link() { return if link.is_relative() { - Some(path.join(link)) + if let Some(parent) = path.parent(){ + Some(parent.join(link)) + }else{ + None + } } else { Some(link) }; diff --git a/src/main.rs b/src/main.rs index 7cbf69c..904fe95 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ use tux_icons::icon_fetcher::IconFetcher; fn main(){ let fetcher = IconFetcher::new().set_return_target_path(true); - let path = fetcher.get_icon_path_from_desktop("/usr/share/applications/nwg-look.desktop"); + let path = fetcher.get_icon_path_from_desktop("/usr/share/applications/blueman-adapters.desktop"); println!("Path: {:?}", path); } \ No newline at end of file