Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: icons.yaml does not seem to override icons #1082

Open
1 task done
hawkw opened this issue Aug 16, 2024 · 0 comments
Open
1 task done

[Bug]: icons.yaml does not seem to override icons #1082

hawkw opened this issue Aug 16, 2024 · 0 comments
Assignees

Comments

@hawkw
Copy link

hawkw commented Aug 16, 2024

Version

  • latest

version

eliza@theseus ~ $ lsd --version
lsd 1.1.2

What OS are you seeing the problem on?

Linux

installation

From Nixpkgs

term

eliza@theseus ~ $ echo $TERM
alacritty

ls-colors

eliza@theseus ~ $ echo $LS_COLORS
rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=00:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.7z=01;31:*.ace=01;31:*.alz=01;31:*.apk=01;31:*.arc=01;31:*.arj=01;31:*.bz=01;31:*.bz2=01;31:*.cab=01;31:*.cpio=01;31:*.crate=01;31:*.deb=01;31:*.drpm=01;31:*.dwm=01;31:*.dz=01;31:*.ear=01;31:*.egg=01;31:*.esd=01;31:*.gz=01;31:*.jar=01;31:*.lha=01;31:*.lrz=01;31:*.lz=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.lzo=01;31:*.pyz=01;31:*.rar=01;31:*.rpm=01;31:*.rz=01;31:*.sar=01;31:*.swm=01;31:*.t7z=01;31:*.tar=01;31:*.taz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tgz=01;31:*.tlz=01;31:*.txz=01;31:*.tz=01;31:*.tzo=01;31:*.tzst=01;31:*.udeb=01;31:*.war=01;31:*.whl=01;31:*.wim=01;31:*.xz=01;31:*.z=01;31:*.zip=01;31:*.zoo=01;31:*.zst=01;31:*.avif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:*~=00;90:*#=00;90:*.bak=00;90:*.crdownload=00;90:*.dpkg-dist=00;90:*.dpkg-new=00;90:*.dpkg-old=00;90:*.dpkg-tmp=00;90:*.old=00;90:*.orig=00;90:*.part=00;90:*.rej=00;90:*.rpmnew=00;90:*.rpmorig=00;90:*.rpmsave=00;90:*.swp=00;90:*.tmp=00;90:*.ucf-dist=00;90:*.ucf-new=00;90:*.ucf-old=00;90:

What happened?

I have an icons.yaml file in $HOME/config/lsd/icons.yaml. The icons.theme key in $HOME/.config/lsd/config.yaml is set to "unicode", and icons.when is set to "auto". However, my specified file type icons in icons.yaml do not seem to override the defaults.

For example:

eliza@theseus ~ $ lsd ~/.config/lsd
🔖 config.yaml  🔖 icons.yaml

eliza@theseus ~ $ cat ~/.config/lsd/config.yaml
color:
  when: auto
hyperlink: auto
icons:
  separator: ' '
  theme: unicode
  when: auto

eliza@theseus ~ $ cat ~/.config/lsd/icons.yaml
filetype:
  device_block: 🖴
  device_char: 🖵
  dir: 🗀
  executable: 🗔
  file: 🗎
  pipe: ⭍
  socket: 🖧

eliza@theseus ~ $ ls
📂 Code  📂 Desktop  📂 Documents  📂 Downloads  📄 hubris.core.ringbuf-counts  📂 keybase  📂 Music  📂 Pictures  📂 Public  📄 se.jpeg  📂 Templates  📂 Videos  📄 vudials.log

eliza@theseus ~ $ lsd
📂 Code       📂 Downloads                   📂 Music     📄 se.jpeg    📄 vudials.log
📂 Desktop    📄 hubris.core.ringbuf-counts  📂 Pictures  📂 Templates
📂 Documents  📂 keybase                     📂 Public    📂 Videos

eliza@theseus ~ $ lsd /dev
🖨 autofs           🖨 hidraw2      🖨 kvm           🔖 rtc      🖨 tty26  🖨 tty54        🖨 vcs6
📂 block           🖨 hpet         🔖 log          🖨 rtc0      🖨 tty27  🖨 tty55        🖨 vcs7
🖨 btrfs-control    📂 hugepages   🖨 loop-control  📂 shm      🖨 tty28  🖨 tty56        🖨 vcsa
📂 bus             🖨 hwrng        💽 loop0        🖨 snapshot  🖨 tty29  🖨 tty57        🖨 vcsa1
📂 char            🖨 i2c-0        💽 loop1        📂 snd      🖨 tty3   🖨 tty58        🖨 vcsa2
🖨 console          🖨 i2c-1        💽 loop2        🔖 stderr   🖨 tty30  🖨 tty59        🖨 vcsa3
🔖 core            🖨 i2c-10       💽 loop3        🔖 stdin    🖨 tty31  🖨 tty6         🖨 vcsa4
📂 cpu             🖨 i2c-11       💽 loop4        🔖 stdout   🖨 tty32  🖨 tty60        🖨 vcsa5
🖨 cpu_dma_latency  🖨 i2c-12       💽 loop5        🖨 tee0      🖨 tty33  🖨 tty61        🖨 vcsa6
🖨 cuse             🖨 i2c-13       💽 loop6        🖨 tpm0      🖨 tty34  🖨 tty62        🖨 vcsa7
🖨 dbc              🖨 i2c-14       💽 loop7        🖨 tpmrm0    🖨 tty35  🖨 tty63        🖨 vcsu
📂 disk            🖨 i2c-15       📂 mapper       🖨 tty       🖨 tty36  🖨 tty7         🖨 vcsu1
💽 dm-0            🖨 i2c-16       🖨 media0        🖨 tty0      🖨 tty37  🖨 tty8         🖨 vcsu2
💽 dm-1            🖨 i2c-17       🖨 mem           🖨 tty1      🖨 tty38  🖨 tty9         🖨 vcsu3
📂 dri             🖨 i2c-18       📂 mqueue       🖨 tty10     🖨 tty39  🖨 ttyS0        🖨 vcsu4
🖨 drm_dp_aux0      🖨 i2c-19       📂 net          🖨 tty11     🖨 tty4   🖨 ttyS1        🖨 vcsu5
🖨 drm_dp_aux1      🖨 i2c-2        🖨 ng0n1         🖨 tty12     🖨 tty40  🖨 ttyS2        🖨 vcsu6
🖨 drm_dp_aux2      🖨 i2c-20       🖨 null          🖨 tty13     🖨 tty41  🖨 ttyS3        🖨 vcsu7
🖨 drm_dp_aux3      🖨 i2c-21       🖨 nvme0         🖨 tty14     🖨 tty42  🖨 udmabuf      📂 vfio
🖨 drm_dp_aux4      🖨 i2c-22       💽 nvme0n1      🖨 tty15     🖨 tty43  🖨 uhid         🖨 vga_arbiter
🖨 drm_dp_aux5      🖨 i2c-3        💽 nvme0n1p1    🖨 tty16     🖨 tty44  🖨 uinput       🖨 vhci
🖨 drm_dp_aux6      🖨 i2c-4        💽 nvme0n1p2    🖨 tty17     🖨 tty45  🖨 urandom      🖨 vhost-net
🖨 drm_dp_aux7      🖨 i2c-5        💽 nvme0n1p3    🖨 tty18     🖨 tty46  🖨 userfaultfd  🖨 vhost-vsock
🖨 drm_dp_aux8      🖨 i2c-6        🖨 nvram         🖨 tty19     🖨 tty47  🖨 userio       🖨 video0
🖨 fb0              🖨 i2c-7        🖨 port          🖨 tty2      🖨 tty48  📂 v4l         🖨 video1
🗂 fd               🖨 i2c-8        🖨 ppp           🖨 tty20     🖨 tty49  🖨 vcs          🖨 watchdog
🖨 full             🖨 i2c-9        🖨 ptmx          🖨 tty21     🖨 tty5   🖨 vcs1         🖨 watchdog0
🖨 fuse             🖨 iio:device0  📂 pts          🖨 tty22     🖨 tty50  🖨 vcs2         🖨 zero
🖨 gpiochip0        📂 input       🖨 random        🖨 tty23     🖨 tty51  🖨 vcs3
🖨 hidraw0          🖨 kfd          🖨 rfkill        🖨 tty24     🖨 tty52  🖨 vcs4
🖨 hidraw1          🖨 kmsg         🔖 root         🖨 tty25     🖨 tty53  🖨 vcs5

eliza@theseus ~ $

Note that the overridden directory, block device, char device, and file icons in icons.yaml are not used.

What expected?

I would have expected the overridden icons to be used, as described in the README here.

What else?

It seems like the documentation on setting a custom icon theme in the README may no longer describe lsd's actual behavior? Looking at lsd/src/theme.rs, it looks like the Theme struct now attempts to parse an icon theme, color theme, and Git symbols from the same file:

lsd/src/theme.rs

Lines 18 to 26 in 9b310da

#[derive(Debug, Deserialize, Default, PartialEq, Eq)]
#[serde(rename_all = "kebab-case")]
#[serde(deny_unknown_fields)]
#[serde(default)]
pub struct Theme {
pub color: ColorTheme,
pub icon: IconTheme,
pub git_theme: GitThemeSymbols,
}

lsd/src/theme.rs

Lines 39 to 83 in 9b310da

/// Read theme from a file path
/// use the file path as-is if it is absolute
/// search the config paths folders for it if not
pub fn from_path<D>(file: &str) -> Result<D, Error>
where
D: DeserializeOwned + Default,
{
let real = if let Some(path) = config_file::expand_home(file) {
path
} else {
print_error!("Not a valid theme file path: {}.", &file);
return Err(Error::InvalidPath(file.to_string()));
};
let mut paths = if Path::new(&real).is_absolute() {
vec![real].into_iter()
} else {
config_file::Config::config_paths()
.map(|p| p.join(real.clone()))
.collect::<Vec<_>>()
.into_iter()
};
let Some(valid) = paths.find_map(|p| {
let yaml = p.with_extension("yaml");
let yml = p.with_extension("yml");
if yaml.is_file() {
Some(yaml)
} else if yml.is_file() {
Some(yml)
} else {
None
}
}) else {
return Err(Error::InvalidPath("No valid theme file found".to_string()));
};
match fs::read_to_string(valid) {
Ok(yaml) => match Self::with_yaml(&yaml) {
Ok(t) => Ok(t),
Err(e) => Err(Error::InvalidFormat(e)),
},
Err(e) => Err(Error::ReadFailed(e)),
}
}

I'd be happy to open a PR to either update the documentation or fix the implementation so that it does what the documentation says! However, before doing that, it would be great to hear from the maintainers regarding what the intended behavior here is. Is the icon theme still supposed to be parsed from $XDG_CONFIG_HOME/lsd/icons.yaml as described in the README, or is the apparent behavior of parsing both the icons and color theme from the same YAML file correct? If the current behavior is intended, how is the new theme file supposed to be used --- where should it be located, and how do I point lsd at it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants