os release thingy at bottom
This commit is contained in:
		@@ -78,6 +78,9 @@
 | 
			
		||||
                  <object class="GtkLabel" id="message_label">
 | 
			
		||||
                      <property name="visible">True</property>
 | 
			
		||||
		      <property name="label"></property>
 | 
			
		||||
		      <style>
 | 
			
		||||
	                <class name="msg"/>
 | 
			
		||||
		      </style>
 | 
			
		||||
                  </object>
 | 
			
		||||
                </child>
 | 
			
		||||
              </object>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										25
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								src/main.rs
									
									
									
									
									
								
							@@ -6,6 +6,8 @@ use lightdm;
 | 
			
		||||
use lightdm::{GreeterExt, SessionExt, UserExt, UserListExt};
 | 
			
		||||
use std::cell::RefCell;
 | 
			
		||||
use std::rc::Rc;
 | 
			
		||||
use std::{fs,io};
 | 
			
		||||
use std::io::prelude::*;
 | 
			
		||||
 | 
			
		||||
fn main() {
 | 
			
		||||
    if gtk::init().is_err() {
 | 
			
		||||
@@ -22,6 +24,12 @@ fn main() {
 | 
			
		||||
        handler_borrowed.setup_greeter(handler.clone());
 | 
			
		||||
        handler_borrowed.setup_de_select(handler.clone());
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        let handler_borrowed = handler.borrow();
 | 
			
		||||
        if let Ok(os_str) = pretty_name() {
 | 
			
		||||
            handler_borrowed.msg_label.as_ref().expect("no msg label").set_text(&os_str);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        let handler_borrowed = handler.borrow();
 | 
			
		||||
        let greeter = handler_borrowed.greeter.as_ref().expect("no greeter");
 | 
			
		||||
@@ -217,3 +225,20 @@ impl Handler {
 | 
			
		||||
        vbox.show_all()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn pretty_name() -> Result<String, io::Error> {
 | 
			
		||||
    let file = fs::File::open("/etc/os-release")?;
 | 
			
		||||
    let contents = io::BufReader::new(file);
 | 
			
		||||
    for line_opt in contents.lines() {
 | 
			
		||||
        let line = line_opt?;
 | 
			
		||||
        if line.starts_with("PRETTY_NAME=") {
 | 
			
		||||
            if let Some(name) = line.split("=").skip(1).next() {
 | 
			
		||||
                return Ok(name.trim_matches('"').to_string());
 | 
			
		||||
            };
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    Err(io::Error::new(
 | 
			
		||||
        io::ErrorKind::NotFound,
 | 
			
		||||
        "I tried my best :)",
 | 
			
		||||
    ))
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user