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 {
|
||||
ActionType::Details => {
|
||||
print(&title, true, &(color.to_owned() + "_bold"));
|
||||
for _ in 0..(10 - title.len()) {
|
||||
for _ in 0..(12 - title.len()) {
|
||||
print!(" ");
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
);
|
||||
|
|
|
@ -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()
|
||||
}
|
Loading…
Reference in a new issue