Adds some os detection, ubuntu logo
This commit is contained in:
		
							parent
							
								
									a3f18d271d
								
							
						
					
					
						commit
						36a6ec1e12
					
				
							
								
								
									
										26
									
								
								src/lib.rs
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								src/lib.rs
									
									
									
									
									
								
							@ -6,28 +6,51 @@ pub mod logos;
 | 
			
		||||
#[derive(Copy, Clone, Debug)]
 | 
			
		||||
pub enum Os {
 | 
			
		||||
    ArchLinux,
 | 
			
		||||
    Debian,
 | 
			
		||||
    Manjaro,
 | 
			
		||||
    Mint,
 | 
			
		||||
    Suse,
 | 
			
		||||
    Ubuntu,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Os {
 | 
			
		||||
    pub fn detect() -> Option<Os> {
 | 
			
		||||
        Some(Os::ArchLinux)
 | 
			
		||||
        let lsb_release = lsb_release().unwrap();
 | 
			
		||||
 | 
			
		||||
        match lsb_release.trim() {
 | 
			
		||||
            "archlinux" | "Arch Linux" | "arch" | "Arch" | "archarm" =>  Some(Os::ArchLinux),
 | 
			
		||||
            "Debian" => Some(Os::Debian),
 | 
			
		||||
            "ManjaroLinux" => Some(Os::Manjaro),
 | 
			
		||||
            "LinuxMint" => Some(Os::Mint),
 | 
			
		||||
            "openSUSE" | "openSUSE project" | "SUSE LINUX" | "SUSE" => Some(Os::Suse),
 | 
			
		||||
            "Ubuntu" => Some(Os::Ubuntu),
 | 
			
		||||
 | 
			
		||||
            _ => None,
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn ascii_logo(self) -> &'static str {
 | 
			
		||||
        match self {
 | 
			
		||||
            Os::ArchLinux => logos::archlinux::ASCII_LOGO,
 | 
			
		||||
            Os::Ubuntu => logos::ubuntu::ASCII_LOGO,
 | 
			
		||||
            _ => unimplemented!(),
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn name(self) -> &'static str {
 | 
			
		||||
        match self {
 | 
			
		||||
            Os::ArchLinux => "Arch Linux",
 | 
			
		||||
            Os::Ubuntu => "Ubuntu",
 | 
			
		||||
            _ => unimplemented!(),
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn style(self) -> &'static str {
 | 
			
		||||
        match self {
 | 
			
		||||
            Os::ArchLinux => "\x1B[36;1m",
 | 
			
		||||
            Os::Ubuntu => "\x1B[31;1m",
 | 
			
		||||
            _ => unimplemented!(),
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -49,4 +72,5 @@ macro_rules! define_command_function {
 | 
			
		||||
 | 
			
		||||
define_command_function!(kernel, "uname", ["-msr"]);
 | 
			
		||||
define_command_function!(uptime, "uptime", ["-p"]);
 | 
			
		||||
define_command_function!(lsb_release, "lsb_release", ["-si"]);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1 +1,2 @@
 | 
			
		||||
pub mod archlinux;
 | 
			
		||||
pub mod ubuntu;
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										20
									
								
								src/logos/ubuntu.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								src/logos/ubuntu.rs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,20 @@
 | 
			
		||||
pub const ASCII_LOGO: &'static str = " \
 | 
			
		||||
\n                         \x1B[31;1m./+o+-\x1B[0m       \
 | 
			
		||||
\n                 \x1B[1myyyyy-\x1B[0m \x1B[31;1m-yyyyyy+\x1B[0m      \
 | 
			
		||||
\n              \x1B[1m://+//////\x1B[31;1m-yyyyyyo\x1B[0m      \
 | 
			
		||||
\n          \x1B[33;1m.++ \x1B[0;1m.:/++++++/-\x1B[31;1m.+sss/`\x1B[0m      \
 | 
			
		||||
\n        \x1B[33;1m.:++o:  \x1B[0;1m/++++++++/:--:/-\x1B[0m      \
 | 
			
		||||
\n       \x1B[33;1mo:+o+:++.\x1B[0;1m`..```.-/oo+++++/\x1B[0m     \
 | 
			
		||||
\n      \x1B[33;1m.:+o:+o/.\x1B[0m          \x1B[1m`+sssoo+/\x1B[0m    \
 | 
			
		||||
\n \x1B[0;1m.++/+:\x1B[33;1m+oo+o:`\x1B[0m             \x1B[1m/sssooo.\x1B[0m   \
 | 
			
		||||
\n/\x1B[0;1m+++//+:\x1B[33;1m`oo+o\x1B[0m               \x1B[1m/::--:.\x1B[0m   \
 | 
			
		||||
\n\x1B[0;1m\\+/+o+++\x1B[33;1m`o++o\x1B[0m               \x1B[31;1m++////.\x1B[0m   \
 | 
			
		||||
\n \x1B[0;1m.++.o+\x1B[33;1m++oo+:`\x1B[0m             \x1B[31;1m/dddhhh.\x1B[0m   \
 | 
			
		||||
\n      \x1B[33;1m.+.o+oo:.\x1B[0m          \x1B[31;1m`oddhhhh+\x1B[0m    \
 | 
			
		||||
\n       \x1B[33;1m\\+.++o+o`\x1B[31;1m`-````.:ohdhhhhh+\x1B[0m     \
 | 
			
		||||
\n        \x1B[33;1m`:o+++ \x1B[31;1m`ohhhhhhhhyo++os:\x1B[0m      \
 | 
			
		||||
\n          \x1B[33;1m.o:\x1B[31;1m`.syhhhhhhh/\x1B[33;1m.oo++o`\x1B[0m      \
 | 
			
		||||
\n              \x1B[31;1m/osyyyyyyo\x1B[33;1m++ooo+++/\x1B[0m     \
 | 
			
		||||
\n                  \x1B[31;1m````` \x1B[33;1m+oo+++o\\:\x1B[0m     \
 | 
			
		||||
\n                         \x1B[33;1m`oo++.\x1B[0m       \
 | 
			
		||||
\n";
 | 
			
		||||
@ -37,7 +37,7 @@ pub fn main() {
 | 
			
		||||
        info.push(format!("{style}{}:{unstyle} {}\n", split[0], split[1], style = style, unstyle = unstyle));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let mut logo_iterator = Os::ArchLinux.ascii_logo().lines();
 | 
			
		||||
    let mut logo_iterator = os.ascii_logo().lines();
 | 
			
		||||
    let mut info_iterator = info.iter();
 | 
			
		||||
 | 
			
		||||
    loop {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user