smithay/anvil/src/main.rs

49 lines
1.5 KiB
Rust
Raw Normal View History

2021-07-25 08:08:40 +00:00
use slog::{crit, o, Drain};
static POSSIBLE_BACKENDS: &[&str] = &[
2018-05-08 10:47:09 +00:00
#[cfg(feature = "winit")]
2018-05-08 17:39:38 +00:00
"--winit : Run anvil as a X11 or Wayland client using winit.",
#[cfg(feature = "udev")]
"--tty-udev : Run anvil as a tty udev client (requires root if without logind).",
2018-05-08 10:47:09 +00:00
];
fn main() {
// A logger facility, here we use the terminal here
let log = if std::env::var("ANVIL_MUTEX_LOG").is_ok() {
slog::Logger::root(std::sync::Mutex::new(slog_term::term_full().fuse()).fuse(), o!())
} else {
slog::Logger::root(
slog_async::Async::default(slog_term::term_full().fuse()).fuse(),
o!(),
)
};
let _guard = slog_scope::set_global_logger(log.clone());
slog_stdlog::init().expect("Could not setup log backend");
2018-06-27 12:04:29 +00:00
let arg = ::std::env::args().nth(1);
2018-05-08 10:47:09 +00:00
match arg.as_ref().map(|s| &s[..]) {
#[cfg(feature = "winit")]
Some("--winit") => {
2021-07-25 08:08:40 +00:00
slog::info!(log, "Starting anvil with winit backend");
2021-07-08 14:27:12 +00:00
anvil::winit::run_winit(log);
}
2018-05-08 17:39:38 +00:00
#[cfg(feature = "udev")]
Some("--tty-udev") => {
2021-07-25 08:08:40 +00:00
slog::info!(log, "Starting anvil on a tty using udev");
2021-07-08 14:27:12 +00:00
anvil::udev::run_udev(log);
2018-05-08 10:47:09 +00:00
}
2021-06-23 18:01:28 +00:00
Some(other) => {
crit!(log, "Unknown backend: {}", other);
}
None => {
2018-05-08 10:47:09 +00:00
println!("USAGE: anvil --backend");
2018-06-27 12:04:29 +00:00
println!();
2018-05-08 10:47:09 +00:00
println!("Possible backends are:");
for b in POSSIBLE_BACKENDS {
println!("\t{}", b);
}
}
}
}