launcher: scan desktop files directly, keep state in XDG_STATE_HOME
The desktop-entry cache lived in $XDG_CACHE_HOME/wldash/desktop.json. On an NFS-shared home that is a remote read and write on every start (unless the session happens to export a machine-local XDG_CACHE_HOME), and it went stale whenever a package was installed until someone ran --desktop-refresh. Scanning the applications directories takes a few milliseconds over local /usr/share and already happened on a background thread, so the cache bought nothing: drop it, along with simd-json and the serde derives on Desktop. --desktop-refresh stays as a no-op so old key bindings keep working. Calculator history and the prompt saved on Escape are state, not cache: they move to $XDG_STATE_HOME/wldash (~/.local/state), written only on Enter/Escape, and the old cache location is still read as a fallback. With the serde derives gone, two Desktop fields were unused; use them: Type=Link entries now open their URL with xdg-open, and Terminal=true entries run under $TERMINAL -e when it is set. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
03a3c681b0
commit
9953865128
+4
-11
@@ -23,10 +23,7 @@ use event::{Event, Events};
|
||||
use fonts::{FontMap, MaybeFontMap};
|
||||
use keyboard::{KeyRepeatSource, RepeatMessage};
|
||||
use state::State;
|
||||
use utils::{
|
||||
desktop::{load_desktop_files, write_desktop_cache},
|
||||
xdg,
|
||||
};
|
||||
use utils::xdg;
|
||||
use widgets::{Geometry, Widget};
|
||||
|
||||
use std::{
|
||||
@@ -50,7 +47,8 @@ OPTIONS:
|
||||
else ~/.config/wldash/config.yml)
|
||||
--write-default-config [v1|v2|toplevel] generate and write a new config file
|
||||
(v2 by default)
|
||||
--desktop-refresh refresh desktop file cache
|
||||
--desktop-refresh no-op kept for old key bindings
|
||||
(desktop files are scanned at start)
|
||||
"
|
||||
);
|
||||
}
|
||||
@@ -68,9 +66,7 @@ fn ensure_dir_exists(path: &str) {
|
||||
|
||||
fn create_required_directories() {
|
||||
let dir_config_wldash = format!("{}/wldash", xdg::config_folder());
|
||||
let dir_cache_wldash = format!("{}/wldash", xdg::cache_folder());
|
||||
ensure_dir_exists(&dir_config_wldash);
|
||||
ensure_dir_exists(&dir_cache_wldash);
|
||||
}
|
||||
|
||||
/// Default config path. On a shared (e.g. NFS-roamed) home, a host-specific
|
||||
@@ -119,10 +115,7 @@ fn main() {
|
||||
std::process::exit(0);
|
||||
}
|
||||
Some(ref s) if s == "--desktop-refresh" => {
|
||||
let v = load_desktop_files();
|
||||
if let Err(e) = write_desktop_cache(&v) {
|
||||
die(format!("could not write desktop cache: {}", e));
|
||||
}
|
||||
eprintln!("wldash: desktop files are scanned at every start; nothing to refresh");
|
||||
std::process::exit(0);
|
||||
}
|
||||
Some(ref s) if s == "--help" => {
|
||||
|
||||
Reference in New Issue
Block a user