fix(appearance): include XDG_DATA_HOME in icon theme search
This commit is contained in:
parent
b13333ab7c
commit
814978379a
1 changed files with 56 additions and 38 deletions
|
|
@ -3,11 +3,12 @@
|
|||
|
||||
use std::borrow::Cow;
|
||||
use std::collections::BTreeSet;
|
||||
use std::path::Path;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
|
||||
use apply::Apply;
|
||||
use ashpd::desktop::file_chooser::{FileFilter, SelectedFiles};
|
||||
use cosmic::cctk::sctk::reexports::protocols::xdg;
|
||||
use cosmic::config::CosmicTk;
|
||||
use cosmic::cosmic_config::{Config, ConfigSet, CosmicConfigEntry};
|
||||
use cosmic::cosmic_theme::palette::{FromColor, Hsv, Srgb, Srgba};
|
||||
|
|
@ -1482,10 +1483,28 @@ async fn fetch_icon_themes() -> Message {
|
|||
|
||||
let mut buffer = String::new();
|
||||
|
||||
if let Ok(data_dirs) = std::env::var("XDG_DATA_DIRS") {
|
||||
for dir in data_dirs.split_terminator(':') {
|
||||
let icon_dir = Path::new(dir).join("icons");
|
||||
let xdg_data_home = std::env::var("XDG_DATA_HOME")
|
||||
.ok()
|
||||
.and_then(|value| {
|
||||
if value.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(PathBuf::from(value))
|
||||
}
|
||||
})
|
||||
.or_else(dirs::home_dir)
|
||||
.map(|dir| dir.join(".local/share/icons"));
|
||||
|
||||
let xdg_data_dirs = std::env::var("XDG_DATA_DIRS");
|
||||
|
||||
let xdg_data_dirs = xdg_data_dirs
|
||||
.as_ref()
|
||||
.ok()
|
||||
.into_iter()
|
||||
.flat_map(|data_dirs| data_dirs.split_terminator(':'))
|
||||
.map(|dir| Path::new(dir).join("icons"));
|
||||
|
||||
for icon_dir in xdg_data_dirs.chain(xdg_data_home) {
|
||||
let Ok(read_dir) = std::fs::read_dir(&icon_dir) else {
|
||||
continue;
|
||||
};
|
||||
|
|
@ -1532,7 +1551,6 @@ async fn fetch_icon_themes() -> Message {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Message::Entered(icon_themes.into_iter().collect())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue