-
-
Notifications
You must be signed in to change notification settings - Fork 368
Makes icons respect system/user/XDG settings for special directories (Documents, Downloads etc.) #1679
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
base: main
Are you sure you want to change the base?
Conversation
|
CI seems to have failed before even building the project. Some network error in the bsd tests. Maybe rerunning would solve it? https://github.com/eza-community/eza/actions/runs/20288034950/job/58266225590?pr=1679#step:3:1194 |
ariasuni
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to work correctly here:
$ bat ~/.config/user-dirs.dirs
XDG_DESKTOP_DIR="$HOME"
XDG_DOCUMENTS_DIR="$HOME/documents"
XDG_DOWNLOAD_DIR="$HOME/téléchargements"
XDG_MUSIC_DIR="$HOME/musique"
XDG_PICTURES_DIR="$HOME/médias"
XDG_PUBLICSHARE_DIR="$HOME/.local/share/Public/"
XDG_TEMPLATES_DIR="$HOME/.local/share/Templates/"
XDG_VIDEOS_DIR="$HOME/médias"
$ cargo run -- -l --icons ~
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.11s
Running `target/debug/eza -l --icons /home/ariasuni`
drwxr-xr-x - ariasuni 18 déc. 17:46 administratif
drwxr-xr-x - ariasuni 15 déc. 21:47 documents
drwxr-xr-x - ariasuni 26 déc. 19:31 'films et séries'
drwxr-xr-x - ariasuni 28 oct. 16:38 jeux
drwxr-xr-x - ariasuni 15 déc. 18:30 musique
drwxr-xr-x - ariasuni 15 déc. 16:26 médias
drwxr-xr-x - ariasuni 15 mars 18:17 projets
drwxr-xr-x - ariasuni 29 déc. 14:09 téléchargements
So, nice!
I’ll let Windows user comment on what to do about Windows directories.
For the CI we’re working on it: #1669
| if let Some(p) = dirs::config_dir() { | ||
| // NOTE: maybe we should not use this for Windows, since AppData\Roaming is not really | ||
| // a config directory (windows does not split the config and data directories like this) | ||
| map.insert(p, Icons::FOLDER_CONFIG); | ||
| } | ||
|
|
||
| if let Some(p) = dirs::desktop_dir() { | ||
| map.insert(p, Icons::FOLDER_DESKTOP); | ||
| } | ||
|
|
||
| if let Some(p) = dirs::document_dir() { | ||
| map.insert(p, Icons::FOLDER_DOCUMENTS); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn’t test it, but I think it would be nicer if it was written like this:
| if let Some(p) = dirs::config_dir() { | |
| // NOTE: maybe we should not use this for Windows, since AppData\Roaming is not really | |
| // a config directory (windows does not split the config and data directories like this) | |
| map.insert(p, Icons::FOLDER_CONFIG); | |
| } | |
| if let Some(p) = dirs::desktop_dir() { | |
| map.insert(p, Icons::FOLDER_DESKTOP); | |
| } | |
| if let Some(p) = dirs::document_dir() { | |
| map.insert(p, Icons::FOLDER_DOCUMENTS); | |
| } | |
| // NOTE: maybe we should not use this for Windows, since AppData\Roaming is not really | |
| // a config directory (windows does not split the config and data directories like this) | |
| dirs::config_dir().inspect(|p| map.insert(p, Icons::FOLDER_CONFIG)); | |
| dirs::desktop_dir().inspect(|p| map.insert(p, Icons::FOLDER_DESKTOP)); | |
| dirs::document_dir().inspect(|p| map.insert(p, Icons::FOLDER_DOCUMENTS)); |
Everything could then be tightly packed instead of having 3 lines for a simple conditional insert.
Closes #939, following the idea from @cafkafk's comment in that issue.
This relies on the implementation from our dependency dirs. If the user has not set or changed their special directories from the default values, this should have the the exact same output, as it still uses the old string comparison as a fallback.
I have not written tests for this, I welcome some ideas of how to test it. Testing is not trivial, since it's different for each OS family (accounted for by
dirs). I have "tested" it locally on my (Linux) machine and it worked as intended.I think this should also respect localization of those folder names, but I have not tested localizations specifically.
I have left a few comments concerning some icons that don't really match in Windows, since it has a different separation of directories.
Relevant information:
https://wiki.archlinux.org/title/XDG_user_directories
https://specifications.freedesktop.org/basedir/latest/