feat: 🎸 Add init system info

This commit is contained in:
Atsukoro1 2022-12-02 19:37:26 +01:00
parent e469b4c0c5
commit 4394d5eb54
3 changed files with 22 additions and 2 deletions

View file

@ -7,7 +7,7 @@ pub fn print_detail(title: &str, value: String, atype: ActionType, color: &str)
match atype {
ActionType::Details => {
print(&title, true, &(color.to_owned() + "_bold"));
for _ in 0..(10 - title.len()) {
for _ in 0..(12 - title.len()) {
print!(" ");
}

View file

@ -20,7 +20,7 @@ pub struct Action<'a> {
func: Option<fn() -> String>,
}
const ACTIONS: [Action; 12] = [
const ACTIONS: [Action; 13] = [
Action {
action_type: ActionType::HostInfo,
name: None,
@ -71,6 +71,11 @@ const ACTIONS: [Action; 12] = [
name: Some("RAM"),
func: Some(system::specs::get_ram_used),
},
Action {
action_type: ActionType::Details,
name: Some("Init System"),
func: Some(system::host::get_init_system),
},
Action {
action_type: ActionType::Delimiter,
name: None,
@ -86,6 +91,8 @@ const ACTIONS: [Action; 12] = [
fn main() {
let args: Args = Args::parse();
println!("{}", system::host::get_init_system());
let line_count = helpers::file::get_file_linecount(
&format!("{}{}.txt", helpers::paths::get_pony_path(), &args.pony)
);

View file

@ -115,3 +115,16 @@ pub fn get_resolution() -> String {
final_str
}
#[cfg(target_os = "linux")]
pub fn get_init_system() -> String {
Command::new("ps")
.args(&["-p", "1", "-o", "comm="])
.output()
.unwrap()
.stdout
.iter()
.map(|&c| c as char)
.collect::<String>()
.trim().to_string()
}