Skip to content

Commit

Permalink
fix broken paths when returning target path is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
lighttigerXIV committed Sep 21, 2024
1 parent a6efbb3 commit bcc81f3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/icon_fetcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,19 @@ fn get_system_icon_pack() -> String {
fn get_target_path(path: impl Into<PathBuf>) -> Option<PathBuf> {
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)
};
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit bcc81f3

Please sign in to comment.