os release thingy at bottom
This commit is contained in:
parent
914e62493a
commit
4c7a51cacc
|
@ -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>
|
||||||
|
|
25
src/main.rs
25
src/main.rs
|
@ -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 :)",
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue