Skip to content

Commit

Permalink
Allow manually configuring the path to Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
null-dev committed Jun 19, 2021
1 parent 973ea94 commit 2e09bb2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
9 changes: 6 additions & 3 deletions src/cmd/launch_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ pub fn process_cmd_launch_profile(app_state: &AppState,
Err(e) => { log::info!("Failed to focus current browser window, launching new window: {:?}", e); }
}

let parent_proc = match get_parent_proc_path() {
Ok(v) => v,
Err(e) => return NativeResponse::error_with_dbg_msg("Unable to find browser binary!", e)
let parent_proc = match app_state.config.browser_binary() {
Some(v) => v.clone(),
None => match get_parent_proc_path() {
Ok(v) => v,
Err(e) => return NativeResponse::error_with_dbg_msg("Unable to find browser binary!", e)
}
};

if !parent_proc.exists() {
Expand Down
17 changes: 13 additions & 4 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,25 @@ use std::fs::OpenOptions;

#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Config {
pub browser_profile_dir: PathBuf
browser_profile_dir: Option<PathBuf>,
browser_binary: Option<PathBuf>
}

impl Config {
pub fn browser_profile_dir(&self) -> PathBuf {
self.browser_profile_dir.clone().unwrap_or_else(get_default_browser_profile_folder)
}
pub fn browser_binary(&self) -> Option<&PathBuf> {
self.browser_binary.as_ref()
}

pub fn profiles_ini_path(&self) -> PathBuf {
let mut profiles_ini = self.browser_profile_dir.clone();
let mut profiles_ini = self.browser_profile_dir().clone();
profiles_ini.push("profiles.ini");
return profiles_ini;
}
pub fn installs_ini_path(&self) -> PathBuf {
let mut installs_ini = self.browser_profile_dir.clone();
let mut installs_ini = self.browser_profile_dir().clone();
installs_ini.push("installs.ini");
return installs_ini;
}
Expand Down Expand Up @@ -51,7 +59,8 @@ fn get_default_browser_profile_folder() -> PathBuf {
impl Default for Config {
fn default() -> Self {
Config {
browser_profile_dir: get_default_browser_profile_folder()
browser_profile_dir: None,
browser_binary: None
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/profiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub struct ProfileEntry {
impl ProfileEntry {
pub fn full_path(&self, config: &Config) -> PathBuf {
return if self.is_relative {
let mut result = config.browser_profile_dir.clone();
let mut result = config.browser_profile_dir().clone();
result.push(&self.path);
result
} else {
Expand Down

0 comments on commit 2e09bb2

Please sign in to comment.