mirror of
https://github.com/Atsukoro1/ponyfetch.git
synced 2024-11-27 06:17:59 +01:00
feat: 🎸 Add init system info
This commit is contained in:
parent
e469b4c0c5
commit
4394d5eb54
3 changed files with 22 additions and 2 deletions
|
@ -7,7 +7,7 @@ pub fn print_detail(title: &str, value: String, atype: ActionType, color: &str)
|
||||||
match atype {
|
match atype {
|
||||||
ActionType::Details => {
|
ActionType::Details => {
|
||||||
print(&title, true, &(color.to_owned() + "_bold"));
|
print(&title, true, &(color.to_owned() + "_bold"));
|
||||||
for _ in 0..(10 - title.len()) {
|
for _ in 0..(12 - title.len()) {
|
||||||
print!(" ");
|
print!(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ pub struct Action<'a> {
|
||||||
func: Option<fn() -> String>,
|
func: Option<fn() -> String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
const ACTIONS: [Action; 12] = [
|
const ACTIONS: [Action; 13] = [
|
||||||
Action {
|
Action {
|
||||||
action_type: ActionType::HostInfo,
|
action_type: ActionType::HostInfo,
|
||||||
name: None,
|
name: None,
|
||||||
|
@ -71,6 +71,11 @@ const ACTIONS: [Action; 12] = [
|
||||||
name: Some("RAM"),
|
name: Some("RAM"),
|
||||||
func: Some(system::specs::get_ram_used),
|
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 {
|
||||||
action_type: ActionType::Delimiter,
|
action_type: ActionType::Delimiter,
|
||||||
name: None,
|
name: None,
|
||||||
|
@ -86,6 +91,8 @@ const ACTIONS: [Action; 12] = [
|
||||||
fn main() {
|
fn main() {
|
||||||
let args: Args = Args::parse();
|
let args: Args = Args::parse();
|
||||||
|
|
||||||
|
println!("{}", system::host::get_init_system());
|
||||||
|
|
||||||
let line_count = helpers::file::get_file_linecount(
|
let line_count = helpers::file::get_file_linecount(
|
||||||
&format!("{}{}.txt", helpers::paths::get_pony_path(), &args.pony)
|
&format!("{}{}.txt", helpers::paths::get_pony_path(), &args.pony)
|
||||||
);
|
);
|
||||||
|
|
|
@ -114,4 +114,17 @@ pub fn get_resolution() -> String {
|
||||||
});
|
});
|
||||||
|
|
||||||
final_str
|
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()
|
||||||
}
|
}
|
Loading…
Reference in a new issue