diff --git a/interface.ui b/interface.ui index f3bbafa..0ddda8f 100644 --- a/interface.ui +++ b/interface.ui @@ -77,7 +77,10 @@ True - + + diff --git a/src/main.rs b/src/main.rs index 846415d..4821ee8 100644 --- a/src/main.rs +++ b/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 { + 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 :)", + )) +} diff --git a/style.css b/style.css index 7879a93..936f980 100644 --- a/style.css +++ b/style.css @@ -51,3 +51,8 @@ popover { popover radiobutton { padding: 1em; } + +.msg { + font-size: 1.5em; + padding: 1em; +}