cosmic-greeter/src/main.rs

55 lines
1.6 KiB
Rust
Raw Normal View History

2023-09-29 16:02:45 -06:00
// Copyright 2023 System76 <info@system76.com>
2023-10-05 17:47:23 -06:00
// SPDX-License-Identifier: GPL-3.0-only
2023-09-29 16:02:45 -06:00
2025-03-25 11:10:47 -04:00
use clap_lex::RawArgs;
use cosmic_greeter::{greeter, locker};
2025-03-25 11:10:47 -04:00
use std::error::Error;
2024-01-17 12:37:22 -07:00
2025-03-25 11:10:47 -04:00
fn main() -> Result<(), Box<dyn Error>> {
let raw_args = RawArgs::from_args();
let mut cursor = raw_args.cursor();
// Parse the arguments
2025-03-25 11:10:47 -04:00
while let Some(arg) = raw_args.next_os(&mut cursor) {
match arg.to_str() {
Some("--help") | Some("-h") => {
print_help(env!("CARGO_PKG_VERSION"), env!("VERGEN_GIT_SHA"));
return Ok(());
}
2025-03-25 11:10:47 -04:00
Some("--version") | Some("-v") => {
println!(
"cosmic-greeter {} (git commit {})",
env!("CARGO_PKG_VERSION"),
env!("VERGEN_GIT_SHA")
);
return Ok(());
}
_ => {}
}
}
2023-10-05 17:47:23 -06:00
match pwd::Passwd::current_user() {
Some(current_user) => match current_user.name.as_str() {
2024-02-05 12:54:34 -07:00
"cosmic-greeter" => greeter::main(),
2023-10-05 17:47:23 -06:00
_ => locker::main(current_user),
},
_ => Err("failed to determine current user".into()),
2023-09-29 16:02:45 -06:00
}
2023-09-29 09:24:35 -06:00
}
fn print_help(version: &str, git_rev: &str) {
println!(
r#"cosmic-greeter {version} (git commit {git_rev})
System76 <info@system76.com>
Designed for the COSMIC desktop environment, cosmic-greeter is a libcosmic
frontend for greetd which can be run inside of cosmic-comp.
Project home page: https://github.com/pop-os/cosmic-greeter
Options:
-h, --help Show this message
-v, --version Show the version of cosmic-greeter"#
);
}