feat: implement OS bridge and enhance app launcher functionality
This commit is contained in:
@@ -7,15 +7,12 @@ edition = "2024"
|
||||
name = "plugin_apps"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "plugin-apps"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
async-trait = { workspace = true }
|
||||
k-launcher-kernel = { path = "../../k-launcher-kernel" }
|
||||
libc = "0.2"
|
||||
serde = { workspace = true }
|
||||
serde_json = "1.0"
|
||||
tokio = { workspace = true }
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
xdg = "2"
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
pub mod frecency;
|
||||
#[cfg(target_os = "linux")]
|
||||
pub mod linux;
|
||||
|
||||
use std::{collections::HashMap, path::Path, process::{Command, Stdio}, sync::Arc};
|
||||
use std::os::unix::process::CommandExt;
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use k_launcher_kernel::{Plugin, PluginName, ResultId, ResultTitle, Score, SearchResult};
|
||||
use k_launcher_kernel::{LaunchAction, Plugin, PluginName, ResultId, ResultTitle, Score, SearchResult};
|
||||
|
||||
use crate::frecency::FrecencyStore;
|
||||
|
||||
@@ -71,7 +72,8 @@ struct CachedEntry {
|
||||
keywords_lc: Vec<String>,
|
||||
category: Option<String>,
|
||||
icon: Option<String>,
|
||||
on_execute: Arc<dyn Fn() + Send + Sync>,
|
||||
exec: String,
|
||||
on_select: Arc<dyn Fn() + Send + Sync>,
|
||||
}
|
||||
|
||||
// --- Plugin ---
|
||||
@@ -90,27 +92,15 @@ impl AppsPlugin {
|
||||
let id = format!("app-{}", e.name.as_str());
|
||||
let name_lc = e.name.as_str().to_lowercase();
|
||||
let keywords_lc = e.keywords.iter().map(|k| k.to_lowercase()).collect();
|
||||
let icon = e.icon.as_ref().and_then(|p| resolve_icon_path(p.as_str()));
|
||||
let exec = e.exec.clone();
|
||||
#[cfg(target_os = "linux")]
|
||||
let icon = e.icon.as_ref().and_then(|p| linux::resolve_icon_path(p.as_str()));
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
let icon: Option<String> = None;
|
||||
let exec = e.exec.as_str().to_string();
|
||||
let store = Arc::clone(&frecency);
|
||||
let record_id = id.clone();
|
||||
let on_execute: Arc<dyn Fn() + Send + Sync> = Arc::new(move || {
|
||||
let on_select: Arc<dyn Fn() + Send + Sync> = Arc::new(move || {
|
||||
store.record(&record_id);
|
||||
let parts: Vec<&str> = exec.as_str().split_whitespace().collect();
|
||||
if let Some((cmd, args)) = parts.split_first() {
|
||||
let _ = unsafe {
|
||||
Command::new(cmd)
|
||||
.args(args)
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null())
|
||||
.pre_exec(|| {
|
||||
libc::setsid();
|
||||
Ok(())
|
||||
})
|
||||
.spawn()
|
||||
};
|
||||
}
|
||||
});
|
||||
let cached = CachedEntry {
|
||||
id: id.clone(),
|
||||
@@ -118,7 +108,8 @@ impl AppsPlugin {
|
||||
keywords_lc,
|
||||
category: e.category,
|
||||
icon,
|
||||
on_execute,
|
||||
exec,
|
||||
on_select,
|
||||
name: e.name,
|
||||
};
|
||||
(id, cached)
|
||||
@@ -128,19 +119,6 @@ impl AppsPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
fn resolve_icon_path(name: &str) -> Option<String> {
|
||||
if name.starts_with('/') && Path::new(name).exists() {
|
||||
return Some(name.to_string());
|
||||
}
|
||||
let candidates = [
|
||||
format!("/usr/share/pixmaps/{name}.png"),
|
||||
format!("/usr/share/pixmaps/{name}.svg"),
|
||||
format!("/usr/share/icons/hicolor/48x48/apps/{name}.png"),
|
||||
format!("/usr/share/icons/hicolor/scalable/apps/{name}.svg"),
|
||||
];
|
||||
candidates.into_iter().find(|p| Path::new(p).exists())
|
||||
}
|
||||
|
||||
fn initials(name_lc: &str) -> String {
|
||||
name_lc.split_whitespace().filter_map(|w| w.chars().next()).collect()
|
||||
}
|
||||
@@ -153,7 +131,7 @@ fn score_match(name_lc: &str, query_lc: &str) -> Option<u32> {
|
||||
None
|
||||
}
|
||||
|
||||
fn humanize_category(s: &str) -> String {
|
||||
pub(crate) fn humanize_category(s: &str) -> String {
|
||||
let mut result = String::new();
|
||||
for ch in s.chars() {
|
||||
if ch.is_uppercase() && !result.is_empty() {
|
||||
@@ -183,7 +161,8 @@ impl Plugin for AppsPlugin {
|
||||
description: e.category.clone(),
|
||||
icon: e.icon.clone(),
|
||||
score: Score::new(score),
|
||||
on_execute: Arc::clone(&e.on_execute),
|
||||
action: LaunchAction::SpawnProcess(e.exec.clone()),
|
||||
on_select: Some(Arc::clone(&e.on_select)),
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
@@ -202,129 +181,14 @@ impl Plugin for AppsPlugin {
|
||||
description: e.category.clone(),
|
||||
icon: e.icon.clone(),
|
||||
score: Score::new(score),
|
||||
on_execute: Arc::clone(&e.on_execute),
|
||||
action: LaunchAction::SpawnProcess(e.exec.clone()),
|
||||
on_select: Some(Arc::clone(&e.on_select)),
|
||||
})
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
// --- Filesystem source ---
|
||||
|
||||
pub struct FsDesktopEntrySource;
|
||||
|
||||
impl FsDesktopEntrySource {
|
||||
pub fn new() -> Self {
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for FsDesktopEntrySource {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl DesktopEntrySource for FsDesktopEntrySource {
|
||||
fn entries(&self) -> Vec<DesktopEntry> {
|
||||
let mut dirs = Vec::new();
|
||||
if let Ok(xdg) = xdg::BaseDirectories::new() {
|
||||
dirs.push(xdg.get_data_home().join("applications"));
|
||||
for d in xdg.get_data_dirs() {
|
||||
dirs.push(d.join("applications"));
|
||||
}
|
||||
}
|
||||
let mut entries = Vec::new();
|
||||
for dir in &dirs {
|
||||
if let Ok(read_dir) = std::fs::read_dir(dir) {
|
||||
for entry in read_dir.flatten() {
|
||||
let path = entry.path();
|
||||
if path.extension().and_then(|e| e.to_str()) != Some("desktop") {
|
||||
continue;
|
||||
}
|
||||
if let Some(de) = parse_desktop_file(&path) {
|
||||
entries.push(de);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
entries
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_desktop_file(path: &Path) -> Option<DesktopEntry> {
|
||||
let content = std::fs::read_to_string(path).ok()?;
|
||||
let mut in_section = false;
|
||||
let mut name: Option<String> = None;
|
||||
let mut exec: Option<String> = None;
|
||||
let mut icon: Option<String> = None;
|
||||
let mut category: Option<String> = None;
|
||||
let mut keywords: Vec<String> = Vec::new();
|
||||
let mut is_application = false;
|
||||
let mut no_display = false;
|
||||
|
||||
for line in content.lines() {
|
||||
let line = line.trim();
|
||||
if line == "[Desktop Entry]" {
|
||||
in_section = true;
|
||||
continue;
|
||||
}
|
||||
if line.starts_with('[') {
|
||||
in_section = false;
|
||||
continue;
|
||||
}
|
||||
if !in_section || line.starts_with('#') || line.is_empty() {
|
||||
continue;
|
||||
}
|
||||
if let Some((key, value)) = line.split_once('=') {
|
||||
match key.trim() {
|
||||
"Name" if name.is_none() => name = Some(value.trim().to_string()),
|
||||
"Exec" if exec.is_none() => exec = Some(value.trim().to_string()),
|
||||
"Icon" if icon.is_none() => icon = Some(value.trim().to_string()),
|
||||
"Type" if !is_application => is_application = value.trim() == "Application",
|
||||
"NoDisplay" => no_display = value.trim().eq_ignore_ascii_case("true"),
|
||||
"Categories" if category.is_none() => {
|
||||
category = value.trim()
|
||||
.split(';')
|
||||
.find(|s| !s.is_empty())
|
||||
.map(|s| humanize_category(s.trim()));
|
||||
}
|
||||
"Keywords" if keywords.is_empty() => {
|
||||
keywords = value.trim()
|
||||
.split(';')
|
||||
.filter(|s| !s.is_empty())
|
||||
.map(|s| s.trim().to_string())
|
||||
.collect();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !is_application || no_display {
|
||||
return None;
|
||||
}
|
||||
|
||||
let exec_clean: String = exec?
|
||||
.split_whitespace()
|
||||
.filter(|s| !s.starts_with('%'))
|
||||
.fold(String::new(), |mut acc, s| {
|
||||
if !acc.is_empty() {
|
||||
acc.push(' ');
|
||||
}
|
||||
acc.push_str(s);
|
||||
acc
|
||||
});
|
||||
|
||||
Some(DesktopEntry {
|
||||
name: AppName::new(name?),
|
||||
exec: ExecCommand::new(exec_clean),
|
||||
icon: icon.map(IconPath::new),
|
||||
category,
|
||||
keywords,
|
||||
})
|
||||
}
|
||||
|
||||
// --- Tests ---
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
133
crates/plugins/plugin-apps/src/linux.rs
Normal file
133
crates/plugins/plugin-apps/src/linux.rs
Normal file
@@ -0,0 +1,133 @@
|
||||
#![cfg(target_os = "linux")]
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use crate::{AppName, DesktopEntry, DesktopEntrySource, ExecCommand, IconPath};
|
||||
use crate::humanize_category;
|
||||
|
||||
pub struct FsDesktopEntrySource;
|
||||
|
||||
impl FsDesktopEntrySource {
|
||||
pub fn new() -> Self {
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for FsDesktopEntrySource {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl DesktopEntrySource for FsDesktopEntrySource {
|
||||
fn entries(&self) -> Vec<DesktopEntry> {
|
||||
let mut dirs = Vec::new();
|
||||
if let Ok(xdg) = xdg::BaseDirectories::new() {
|
||||
dirs.push(xdg.get_data_home().join("applications"));
|
||||
for d in xdg.get_data_dirs() {
|
||||
dirs.push(d.join("applications"));
|
||||
}
|
||||
}
|
||||
let mut entries = Vec::new();
|
||||
for dir in &dirs {
|
||||
if let Ok(read_dir) = std::fs::read_dir(dir) {
|
||||
for entry in read_dir.flatten() {
|
||||
let path = entry.path();
|
||||
if path.extension().and_then(|e| e.to_str()) != Some("desktop") {
|
||||
continue;
|
||||
}
|
||||
if let Some(de) = parse_desktop_file(&path) {
|
||||
entries.push(de);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
entries
|
||||
}
|
||||
}
|
||||
|
||||
pub fn resolve_icon_path(name: &str) -> Option<String> {
|
||||
if name.starts_with('/') && Path::new(name).exists() {
|
||||
return Some(name.to_string());
|
||||
}
|
||||
let candidates = [
|
||||
format!("/usr/share/pixmaps/{name}.png"),
|
||||
format!("/usr/share/pixmaps/{name}.svg"),
|
||||
format!("/usr/share/icons/hicolor/48x48/apps/{name}.png"),
|
||||
format!("/usr/share/icons/hicolor/scalable/apps/{name}.svg"),
|
||||
];
|
||||
candidates.into_iter().find(|p| Path::new(p).exists())
|
||||
}
|
||||
|
||||
fn parse_desktop_file(path: &Path) -> Option<DesktopEntry> {
|
||||
let content = std::fs::read_to_string(path).ok()?;
|
||||
let mut in_section = false;
|
||||
let mut name: Option<String> = None;
|
||||
let mut exec: Option<String> = None;
|
||||
let mut icon: Option<String> = None;
|
||||
let mut category: Option<String> = None;
|
||||
let mut keywords: Vec<String> = Vec::new();
|
||||
let mut is_application = false;
|
||||
let mut no_display = false;
|
||||
|
||||
for line in content.lines() {
|
||||
let line = line.trim();
|
||||
if line == "[Desktop Entry]" {
|
||||
in_section = true;
|
||||
continue;
|
||||
}
|
||||
if line.starts_with('[') {
|
||||
in_section = false;
|
||||
continue;
|
||||
}
|
||||
if !in_section || line.starts_with('#') || line.is_empty() {
|
||||
continue;
|
||||
}
|
||||
if let Some((key, value)) = line.split_once('=') {
|
||||
match key.trim() {
|
||||
"Name" if name.is_none() => name = Some(value.trim().to_string()),
|
||||
"Exec" if exec.is_none() => exec = Some(value.trim().to_string()),
|
||||
"Icon" if icon.is_none() => icon = Some(value.trim().to_string()),
|
||||
"Type" if !is_application => is_application = value.trim() == "Application",
|
||||
"NoDisplay" => no_display = value.trim().eq_ignore_ascii_case("true"),
|
||||
"Categories" if category.is_none() => {
|
||||
category = value.trim()
|
||||
.split(';')
|
||||
.find(|s| !s.is_empty())
|
||||
.map(|s| humanize_category(s.trim()));
|
||||
}
|
||||
"Keywords" if keywords.is_empty() => {
|
||||
keywords = value.trim()
|
||||
.split(';')
|
||||
.filter(|s| !s.is_empty())
|
||||
.map(|s| s.trim().to_string())
|
||||
.collect();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !is_application || no_display {
|
||||
return None;
|
||||
}
|
||||
|
||||
let exec_clean: String = exec?
|
||||
.split_whitespace()
|
||||
.filter(|s| !s.starts_with('%'))
|
||||
.fold(String::new(), |mut acc, s| {
|
||||
if !acc.is_empty() {
|
||||
acc.push(' ');
|
||||
}
|
||||
acc.push_str(s);
|
||||
acc
|
||||
});
|
||||
|
||||
Some(DesktopEntry {
|
||||
name: AppName::new(name?),
|
||||
exec: ExecCommand::new(exec_clean),
|
||||
icon: icon.map(IconPath::new),
|
||||
category,
|
||||
keywords,
|
||||
})
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
fn main() {}
|
||||
@@ -1,7 +1,5 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use k_launcher_kernel::{Plugin, PluginName, ResultId, ResultTitle, Score, SearchResult};
|
||||
use k_launcher_kernel::{LaunchAction, Plugin, PluginName, ResultId, ResultTitle, Score, SearchResult};
|
||||
|
||||
pub struct CalcPlugin;
|
||||
|
||||
@@ -46,27 +44,14 @@ impl Plugin for CalcPlugin {
|
||||
};
|
||||
let display = format!("= {value_str}");
|
||||
let expr_owned = expr.to_string();
|
||||
let clipboard_val = value_str;
|
||||
vec![SearchResult {
|
||||
id: ResultId::new("calc-result"),
|
||||
title: ResultTitle::new(display),
|
||||
description: Some(format!("{expr_owned} · Enter to copy")),
|
||||
icon: None,
|
||||
score: Score::new(90),
|
||||
on_execute: Arc::new(move || {
|
||||
if std::process::Command::new("wl-copy").arg(&clipboard_val).spawn().is_err() {
|
||||
use std::io::Write;
|
||||
if let Ok(mut child) = std::process::Command::new("xclip")
|
||||
.args(["-selection", "clipboard"])
|
||||
.stdin(std::process::Stdio::piped())
|
||||
.spawn()
|
||||
{
|
||||
if let Some(stdin) = child.stdin.as_mut() {
|
||||
let _ = stdin.write_all(clipboard_val.as_bytes());
|
||||
}
|
||||
}
|
||||
}
|
||||
}),
|
||||
action: LaunchAction::CopyToClipboard(value_str),
|
||||
on_select: None,
|
||||
}]
|
||||
}
|
||||
_ => vec![],
|
||||
|
||||
@@ -10,7 +10,6 @@ path = "src/lib.rs"
|
||||
[dependencies]
|
||||
async-trait = { workspace = true }
|
||||
k-launcher-kernel = { path = "../../k-launcher-kernel" }
|
||||
libc = "0.2"
|
||||
|
||||
[dev-dependencies]
|
||||
tokio = { workspace = true }
|
||||
|
||||
@@ -1,56 +1,5 @@
|
||||
use std::{process::{Command, Stdio}, sync::Arc};
|
||||
use std::os::unix::process::CommandExt;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use k_launcher_kernel::{Plugin, PluginName, ResultId, ResultTitle, Score, SearchResult};
|
||||
|
||||
fn parse_term_cmd(s: &str) -> (String, Vec<String>) {
|
||||
let mut parts = s.split_whitespace();
|
||||
let bin = parts.next().unwrap_or("").to_string();
|
||||
let args = parts.map(str::to_string).collect();
|
||||
(bin, args)
|
||||
}
|
||||
|
||||
fn which(bin: &str) -> bool {
|
||||
Command::new("which")
|
||||
.arg(bin)
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null())
|
||||
.status()
|
||||
.map(|s| s.success())
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
fn resolve_terminal() -> Option<(String, Vec<String>)> {
|
||||
if let Ok(val) = std::env::var("TERM_CMD") {
|
||||
let val = val.trim().to_string();
|
||||
if !val.is_empty() {
|
||||
let (bin, args) = parse_term_cmd(&val);
|
||||
if !bin.is_empty() {
|
||||
return Some((bin, args));
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Ok(val) = std::env::var("TERMINAL") {
|
||||
let bin = val.trim().to_string();
|
||||
if !bin.is_empty() {
|
||||
return Some((bin, vec!["-e".to_string()]));
|
||||
}
|
||||
}
|
||||
for (bin, flag) in &[
|
||||
("foot", "-e"),
|
||||
("kitty", "-e"),
|
||||
("alacritty", "-e"),
|
||||
("wezterm", "start"),
|
||||
("konsole", "-e"),
|
||||
("xterm", "-e"),
|
||||
] {
|
||||
if which(bin) {
|
||||
return Some((bin.to_string(), vec![flag.to_string()]));
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
use k_launcher_kernel::{LaunchAction, Plugin, PluginName, ResultId, ResultTitle, Score, SearchResult};
|
||||
|
||||
pub struct CmdPlugin;
|
||||
|
||||
@@ -80,26 +29,14 @@ impl Plugin for CmdPlugin {
|
||||
if cmd.is_empty() {
|
||||
return vec![];
|
||||
}
|
||||
let cmd_owned = cmd.to_string();
|
||||
vec![SearchResult {
|
||||
id: ResultId::new(format!("cmd-{cmd}")),
|
||||
title: ResultTitle::new(format!("Run: {cmd}")),
|
||||
description: None,
|
||||
icon: None,
|
||||
score: Score::new(95),
|
||||
on_execute: Arc::new(move || {
|
||||
let Some((term_bin, term_args)) = resolve_terminal() else { return };
|
||||
let _ = unsafe {
|
||||
Command::new(&term_bin)
|
||||
.args(&term_args)
|
||||
.arg("sh").arg("-c").arg(&cmd_owned)
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null())
|
||||
.pre_exec(|| { libc::setsid(); Ok(()) })
|
||||
.spawn()
|
||||
};
|
||||
}),
|
||||
action: LaunchAction::SpawnInTerminal(cmd.to_string()),
|
||||
on_select: None,
|
||||
}]
|
||||
}
|
||||
}
|
||||
@@ -130,25 +67,4 @@ mod tests {
|
||||
assert!(p.search("echo hello").await.is_empty());
|
||||
assert!(p.search("firefox").await.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_term_cmd_single_flag() {
|
||||
let (bin, args) = parse_term_cmd("foot -e");
|
||||
assert_eq!(bin, "foot");
|
||||
assert_eq!(args, vec!["-e"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_term_cmd_multiword() {
|
||||
let (bin, args) = parse_term_cmd("wezterm start");
|
||||
assert_eq!(bin, "wezterm");
|
||||
assert_eq!(args, vec!["start"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_term_cmd_no_args() {
|
||||
let (bin, args) = parse_term_cmd("xterm");
|
||||
assert_eq!(bin, "xterm");
|
||||
assert!(args.is_empty());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
mod platform;
|
||||
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use k_launcher_kernel::{Plugin, PluginName, ResultId, ResultTitle, Score, SearchResult};
|
||||
use k_launcher_kernel::{LaunchAction, Plugin, PluginName, ResultId, ResultTitle, Score, SearchResult};
|
||||
|
||||
pub struct FilesPlugin;
|
||||
|
||||
@@ -20,7 +21,7 @@ impl Default for FilesPlugin {
|
||||
|
||||
fn expand_query(query: &str) -> Option<String> {
|
||||
if query.starts_with("~/") {
|
||||
let home = std::env::var("HOME").ok()?;
|
||||
let home = platform::home_dir()?;
|
||||
Some(format!("{}{}", home, &query[1..]))
|
||||
} else if query.starts_with('/') {
|
||||
Some(query.to_string())
|
||||
@@ -87,9 +88,8 @@ impl Plugin for FilesPlugin {
|
||||
description: Some(path_str.clone()),
|
||||
icon: None,
|
||||
score: Score::new(50),
|
||||
on_execute: Arc::new(move || {
|
||||
let _ = std::process::Command::new("xdg-open").arg(&path_str).spawn();
|
||||
}),
|
||||
action: LaunchAction::OpenPath(path_str),
|
||||
on_select: None,
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
|
||||
9
crates/plugins/plugin-files/src/platform.rs
Normal file
9
crates/plugins/plugin-files/src/platform.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
#[cfg(unix)]
|
||||
pub fn home_dir() -> Option<String> {
|
||||
std::env::var("HOME").ok()
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
pub fn home_dir() -> Option<String> {
|
||||
std::env::var("USERPROFILE").ok()
|
||||
}
|
||||
Reference in New Issue
Block a user