1
0
Fork 0

os release thingy at bottom

This commit is contained in:
Raatty 2020-07-16 09:20:03 +00:00
parent 914e62493a
commit 4c7a51cacc
3 changed files with 34 additions and 1 deletions

View File

@ -78,6 +78,9 @@
<object class="GtkLabel" id="message_label"> <object class="GtkLabel" id="message_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label"></property> <property name="label"></property>
<style>
<class name="msg"/>
</style>
</object> </object>
</child> </child>
</object> </object>

View File

@ -6,6 +6,8 @@ use lightdm;
use lightdm::{GreeterExt, SessionExt, UserExt, UserListExt}; use lightdm::{GreeterExt, SessionExt, UserExt, UserListExt};
use std::cell::RefCell; use std::cell::RefCell;
use std::rc::Rc; use std::rc::Rc;
use std::{fs,io};
use std::io::prelude::*;
fn main() { fn main() {
if gtk::init().is_err() { if gtk::init().is_err() {
@ -22,6 +24,12 @@ fn main() {
handler_borrowed.setup_greeter(handler.clone()); handler_borrowed.setup_greeter(handler.clone());
handler_borrowed.setup_de_select(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 handler_borrowed = handler.borrow();
let greeter = handler_borrowed.greeter.as_ref().expect("no greeter"); let greeter = handler_borrowed.greeter.as_ref().expect("no greeter");
@ -217,3 +225,20 @@ impl Handler {
vbox.show_all() 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 :)",
))
}

View File

@ -51,3 +51,8 @@ popover {
popover radiobutton { popover radiobutton {
padding: 1em; padding: 1em;
} }
.msg {
font-size: 1.5em;
padding: 1em;
}