Complete engine rewrite - now featuring Gecko!
This commit is contained in:
parent
d6b604639d
commit
b1be74adb8
20 changed files with 4069 additions and 2309 deletions
73
src/main.rs
73
src/main.rs
|
|
@ -1,8 +1,16 @@
|
|||
//main.rs
|
||||
//! RustyWolf entry point: load config, pick the engine, go.
|
||||
|
||||
mod cli;
|
||||
mod webview;
|
||||
mod config;
|
||||
mod gecko;
|
||||
mod handoff;
|
||||
mod switch;
|
||||
mod util;
|
||||
mod webkit;
|
||||
|
||||
use anyhow::Result;
|
||||
use cli::{Cli, Engine};
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() {
|
||||
if let Err(err) = run() {
|
||||
|
|
@ -12,6 +20,63 @@ fn main() {
|
|||
}
|
||||
|
||||
fn run() -> Result<()> {
|
||||
let cli = cli::Cli::parse_args();
|
||||
webview::launch_webkit(&cli)
|
||||
let cli = Cli::parse_args();
|
||||
let mut cfg = config::load();
|
||||
|
||||
if cli.dry_run {
|
||||
let engine = cli.engine.unwrap_or(cfg.engine);
|
||||
print_dry_run(&cli, &cfg, engine);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if let Some(engine) = cli.engine
|
||||
&& cfg.engine != engine
|
||||
{
|
||||
cfg.engine = engine;
|
||||
config::save(&cfg)?;
|
||||
}
|
||||
if let Some(firefox) = &cli.firefox {
|
||||
cfg.firefox_bin = Some(firefox.clone());
|
||||
config::save(&cfg)?;
|
||||
}
|
||||
|
||||
match cli.engine.unwrap_or(cfg.engine) {
|
||||
Engine::Webkit => webkit::launch(&cli, &mut cfg),
|
||||
Engine::Gecko => gecko::launch(&cli, &mut cfg),
|
||||
}
|
||||
}
|
||||
|
||||
fn print_dry_run(cli: &Cli, cfg: &config::Config, engine: Engine) {
|
||||
let url = cli
|
||||
.url
|
||||
.as_deref()
|
||||
.map(util::normalize_url)
|
||||
.unwrap_or_else(|| util::DEFAULT_HOME.to_string());
|
||||
|
||||
match engine {
|
||||
Engine::Webkit => {
|
||||
let effective_dmabuf =
|
||||
std::env::var("WEBKIT_DISABLE_DMABUF_RENDERER").unwrap_or_else(|_| "0".to_string());
|
||||
println!(
|
||||
"engine=webkit url={url} private={} adblock={} ua={} linux_backend={:?} linux_disable_dmabuf={} effective_webkit_disable_dmabuf={effective_dmabuf}",
|
||||
cli.private,
|
||||
cfg.adblock,
|
||||
if cli.ua_chrome { "chrome" } else { "native" },
|
||||
cli.linux_backend,
|
||||
cli.linux_disable_dmabuf,
|
||||
);
|
||||
}
|
||||
Engine::Gecko => {
|
||||
let firefox: Option<PathBuf> =
|
||||
cli.firefox.clone().or_else(|| gecko::locate_firefox(cfg));
|
||||
let firefox = firefox
|
||||
.map(|path| path.display().to_string())
|
||||
.unwrap_or_else(|| "not-found".to_string());
|
||||
println!(
|
||||
"engine=gecko url={url} private={} firefox={firefox} profile={}",
|
||||
cli.private,
|
||||
config::gecko_profile_dir().display()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue