mirror of
https://github.com/pinnacle-comp/pinnacle.git
synced 2024-12-30 22:23:45 +01:00
Improve run command
This commit is contained in:
parent
34d643aae6
commit
ac57c6896c
1 changed files with 39 additions and 7 deletions
46
src/main.rs
46
src/main.rs
|
@ -41,21 +41,53 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let in_graphical_env =
|
||||||
|
std::env::var("WAYLAND_DISPLAY").is_ok() || std::env::var("DISPLAY").is_ok();
|
||||||
|
|
||||||
let mut args = std::env::args().skip(1);
|
let mut args = std::env::args().skip(1);
|
||||||
match args.next().as_deref() {
|
match args.next().as_deref() {
|
||||||
Some("--winit") => {
|
Some("--winit") => {
|
||||||
tracing::info!("Starting winit backend");
|
if !in_graphical_env {
|
||||||
crate::backend::winit::run_winit()?;
|
if let Some("--force") = args.next().as_deref() {
|
||||||
|
tracing::info!("Starting winit backend with no detected graphical environment");
|
||||||
|
crate::backend::winit::run_winit()?;
|
||||||
|
} else {
|
||||||
|
println!("Both WAYLAND_DISPLAY and DISPLAY were not set.");
|
||||||
|
println!("If you are trying to run the winit backend in a tty, it won't work.");
|
||||||
|
println!("If you really want to, additionally pass in the --force flag.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tracing::info!("Starting winit backend");
|
||||||
|
crate::backend::winit::run_winit()?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Some("--udev") => {
|
Some("--udev") => {
|
||||||
tracing::info!("Starting udev backend");
|
if in_graphical_env {
|
||||||
crate::backend::udev::run_udev()?;
|
if let Some("--force") = args.next().as_deref() {
|
||||||
|
tracing::info!("Starting udev backend with a detected graphical environment");
|
||||||
|
crate::backend::udev::run_udev()?;
|
||||||
|
} else {
|
||||||
|
println!("WAYLAND_DISPLAY and/or DISPLAY were set.");
|
||||||
|
println!(
|
||||||
|
"If you are trying to run the udev backend in a graphical environment,"
|
||||||
|
);
|
||||||
|
println!("it won't work and may mess some things up.");
|
||||||
|
println!("If you really want to, additionally pass in the --force flag.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tracing::info!("Starting udev backend");
|
||||||
|
crate::backend::udev::run_udev()?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Some(arg) => tracing::error!("Unknown argument {}", arg),
|
Some(arg) => tracing::error!("Unknown argument {}", arg),
|
||||||
None => {
|
None => {
|
||||||
println!(
|
if in_graphical_env {
|
||||||
"Specify a backend:\n\t--udev to launch Pinnacle in a tty, or\n\t--winit to launch Pinnacle as a window in your graphical environment."
|
tracing::info!("Starting winit backend");
|
||||||
);
|
crate::backend::winit::run_winit()?;
|
||||||
|
} else {
|
||||||
|
tracing::info!("Starting udev backend");
|
||||||
|
crate::backend::udev::run_udev()?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue