mirror of
https://github.com/Atsukoro1/ponyfetch.git
synced 2024-11-23 20:57:59 +01:00
feat: 🎸 Kernel
This commit is contained in:
parent
028330ab92
commit
2858d3a7d8
7 changed files with 89 additions and 25 deletions
31
ponies/celestia.txt
Normal file
31
ponies/celestia.txt
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
,'/
|
||||||
|
. / ___
|
||||||
|
___/\ / /'`_ `'.
|
||||||
|
__ _ .-' :v :u/ /-'` \ )
|
||||||
|
.-'`` \` \ .'.') ) /\ / / : |
|
||||||
|
.'` .--. ) .)/ / /-'__\// / | |
|
||||||
|
.'` .-'` .| .'.|: @_-'`` \ \/\..--. | ( _.-._
|
||||||
|
,' .'` |' | |'| ( /. '-.__\ ) ( `''.-'` `.
|
||||||
|
.'.-` | .| | | \ ) \__. | | `---`` )
|
||||||
|
.' (_.' | |'.| | ('` ,_ `. : .--. /
|
||||||
|
.' / . | | |' ( \ `\-.-' \ .-'` | \
|
||||||
|
- . (_.-' | | | \ |\ \ __ `` | `''--.,
|
||||||
|
.` .' . / / | | : \| `-._ \.'` '. .--. `-..-'``'. )
|
||||||
|
'-'/ / ( / | : ( |'-, `-.)\ \ .' ) __ ) )
|
||||||
|
/ / /``( .' ( ( '..-':' `-, A ) \_.' (_ .---: )| /
|
||||||
|
/ / / '`' . \ '---''` \ V )`-. .-` '.((( |
|
||||||
|
' / / / `'`(_. `'' .'` )-' `-..___..-'` \ ``.' |
|
||||||
|
( / / / / / / / ,'-` | | \ ''` |
|
||||||
|
'`/ / / / / /.''`.' | : \ |
|
||||||
|
/ / / / /`-' / ..---. | '. \ |
|
||||||
|
( // / /(_/ _ /. . , )/|. '. \ |
|
||||||
|
`-'( / / .-'` ( -(_)- / '| '. (\ |
|
||||||
|
`-'`--' /` \' ' ` .' |. ('.` \ ,.---. |
|
||||||
|
(_ `--''`````\ '| .-` \.-'`_ \ |
|
||||||
|
/ ___ / '..''``''`` `\ . |
|
||||||
|
(``''''`` \ `--'` \ | ..--. |
|
||||||
|
\ (__,..-'` ___ ( '\ .-`__\ \ .--. |
|
||||||
|
'-..----.., ,.-'`` `-. \__.'''` ,' ``--`` '.' |
|
||||||
|
\ .-'` __ .--.-''. .-'``''` |
|
||||||
|
\.-'` .-' `\`'`.'` \_.-' |
|
||||||
|
'.__________.-'` `'`
|
10
src/helpers/file.rs
Normal file
10
src/helpers/file.rs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
use std::{fs::File, io::Read};
|
||||||
|
|
||||||
|
pub fn file_open(path: &str) -> String {
|
||||||
|
let mut temp_buf: String = String::new();
|
||||||
|
|
||||||
|
let mut file = File::open(path).unwrap();
|
||||||
|
file.read_to_string(&mut temp_buf).unwrap();
|
||||||
|
|
||||||
|
temp_buf
|
||||||
|
}
|
1
src/helpers/mod.rs
Normal file
1
src/helpers/mod.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
pub mod file;
|
|
@ -1,5 +1,6 @@
|
||||||
|
mod helpers;
|
||||||
mod system;
|
mod system;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("{}", system::host::get_shell());
|
println!("{}", system::specs::get_kernel());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
|
use crate::helpers::file::file_open;
|
||||||
use std::{fs::File, io::Read};
|
use std::{fs::File, io::Read};
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub fn get_hostname() -> String {
|
pub fn get_hostname() -> String {
|
||||||
let mut hostname = String::new();
|
let mut hostname = file_open("/etc/hostname");
|
||||||
|
|
||||||
let mut f = File::open("/etc/hostname").unwrap();
|
|
||||||
f.read_to_string(&mut hostname).unwrap();
|
|
||||||
|
|
||||||
hostname.pop();
|
hostname.pop();
|
||||||
|
|
||||||
hostname
|
hostname
|
||||||
|
@ -63,12 +60,12 @@ pub fn get_distro() -> String {
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub fn get_uptime() -> String {
|
pub fn get_uptime() -> String {
|
||||||
let mut temp_buf: String = String::new();
|
let mut temp_buf: String = file_open("/proc/uptime");
|
||||||
|
|
||||||
let mut file = File::open("/proc/uptime").unwrap();
|
let uptime: u128 = temp_buf.split(".")
|
||||||
file.read_to_string(&mut temp_buf).unwrap();
|
.collect::<Vec<&str>>()[0]
|
||||||
|
.parse()
|
||||||
let uptime: u128 = temp_buf.split(".").collect::<Vec<&str>>()[0].parse().unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let days = uptime / 86400;
|
let days = uptime / 86400;
|
||||||
let hours = (uptime % 86400) / 3600;
|
let hours = (uptime % 86400) / 3600;
|
||||||
|
@ -80,11 +77,8 @@ pub fn get_uptime() -> String {
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub fn get_shell() -> String {
|
pub fn get_shell() -> String {
|
||||||
|
let temp_buf: String = file_open("/etc/passwd");
|
||||||
let mut final_str = String::new();
|
let mut final_str = String::new();
|
||||||
let mut temp_buf: String = String::new();
|
|
||||||
|
|
||||||
let mut f = File::open("/etc/passwd").unwrap();
|
|
||||||
f.read_to_string(&mut temp_buf).unwrap();
|
|
||||||
|
|
||||||
let lines: &Vec<&str> = &temp_buf.lines().collect();
|
let lines: &Vec<&str> = &temp_buf.lines().collect();
|
||||||
|
|
||||||
|
@ -98,3 +92,26 @@ pub fn get_shell() -> String {
|
||||||
|
|
||||||
final_str
|
final_str
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
pub fn get_resolution() -> String {
|
||||||
|
let mut final_str = String::new();
|
||||||
|
|
||||||
|
let output = Command::new("xrandr")
|
||||||
|
.output()
|
||||||
|
.expect("Failed to execute xrandr");
|
||||||
|
|
||||||
|
let output = String::from_utf8(output.stdout).unwrap();
|
||||||
|
|
||||||
|
let lines: &Vec<&str> = &output.lines().collect();
|
||||||
|
|
||||||
|
lines.into_iter().for_each(|line| {
|
||||||
|
if line.contains(" connected") {
|
||||||
|
final_str = line.split(" ")
|
||||||
|
.collect::<Vec<&str>>()[2]
|
||||||
|
.to_string();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
final_str
|
||||||
|
}
|
|
@ -1,4 +1,3 @@
|
||||||
use std::{fs::File, io::Read};
|
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
|
@ -6,12 +5,10 @@ use std::sync::Mutex;
|
||||||
pub fn get_ipaddr() -> String {
|
pub fn get_ipaddr() -> String {
|
||||||
use std::ops::Add;
|
use std::ops::Add;
|
||||||
|
|
||||||
let mut final_str: Mutex<String> = Mutex::new(String::new());
|
use crate::helpers::file::file_open;
|
||||||
|
|
||||||
let mut f = File::open("/proc/net/route").unwrap();
|
let final_str: Mutex<String> = Mutex::new(String::new());
|
||||||
let mut intr = String::new();
|
let intr = file_open("/proc/net/route");
|
||||||
|
|
||||||
f.read_to_string(&mut intr).unwrap();
|
|
||||||
|
|
||||||
let lines: &Vec<&str> = &intr.lines().collect();
|
let lines: &Vec<&str> = &intr.lines().collect();
|
||||||
let mut interface = String::new();
|
let mut interface = String::new();
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use crate::helpers::file::file_open;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
@ -27,10 +28,7 @@ pub fn get_cpu() -> String {
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub fn get_ram_used() -> String {
|
pub fn get_ram_used() -> String {
|
||||||
let mut temp_buf: String = String::new();
|
let temp_buf: String = file_open("/proc/meminfo");
|
||||||
|
|
||||||
let mut file = File::open("/proc/meminfo").unwrap();
|
|
||||||
file.read_to_string(&mut temp_buf).unwrap();
|
|
||||||
|
|
||||||
let lines: &Vec<&str> = &temp_buf.lines().collect();
|
let lines: &Vec<&str> = &temp_buf.lines().collect();
|
||||||
|
|
||||||
|
@ -64,3 +62,12 @@ fn eval_ram(line: String) -> u128 {
|
||||||
|
|
||||||
(kbs / 1000)
|
(kbs / 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
pub fn get_kernel() -> String {
|
||||||
|
let temp_buf: String = file_open("/proc/version");
|
||||||
|
|
||||||
|
temp_buf.split(" ")
|
||||||
|
.collect::<Vec<&str>>()[2]
|
||||||
|
.to_string()
|
||||||
|
}
|
Loading…
Reference in a new issue