Open rusty-snake opened 3 months ago
Some snippet
diff --git a/src/lib.rs b/src/lib.rs index a292518..dfe5ed0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,7 @@ #![warn(rust_2018_idioms)] use std::borrow::Cow; -use std::env::var_os; +use std::env::{var_os,var}; use std::ffi::OsStr; use std::fs::create_dir; use std::path::PathBuf; @@ -10,13 +10,29 @@ use std::process::Command; pub mod utils; pub fn socket_path() -> PathBuf { + match var("FIREURL_SOCKET") { + Ok(path) if path.starts_with('/') => PathBuf::from(path), + Ok(socket) => { + let mut path = PathBuf::from(var_os("XDG_RUNTIME_DIR").expect("XDG_RUNTIME_DIR not set")); + path.push(socket); + path + } + Err(_) => { + let mut path = PathBuf::from(var_os("XDG_RUNTIME_DIR").expect("XDG_RUNTIME_DIR not set")); + path.push("fireurl/fireurl0"); + path + } + } +} + +/* let mut path = PathBuf::from(var_os("XDG_RUNTIME_DIR").expect("XDG_RUNTIME_DIR not set")); path.push("fireurl/fireurl0"); create_dir(path.parent().unwrap()) .or_else(utils::filter_already_exists) .expect("Failed to create $XDG_RUNTIME_DIR/fireurl."); path -} +*/ /// Checks that `uri` complies to certain restrictions. ///
Some snippet