1
0
Fork 0

Compare commits

...

7 Commits
3 ... master

Author SHA1 Message Date
raatty 8c8d6dfce6 Update 'Cargo.toml' 2022-10-30 11:09:54 +13:00
Raatty e3872c0a69 update lightdm-rs urls 2022-10-30 11:03:43 +13:00
Raatty 3f3bb56290 update lightdm-rs url 2021-10-21 20:55:55 +13:00
Raatty 34df640d5d theming documentation 2020-09-20 08:53:59 +12:00
Raatty e0beba1b89 styling maybe fixed 2020-09-20 08:36:19 +12:00
Raatty e29ec82802 custom styling maybe? 2020-09-16 21:52:26 +12:00
Raatty 4c7a51cacc os release thingy at bottom 2020-07-16 09:20:03 +00:00
6 changed files with 67 additions and 13 deletions

4
Cargo.lock generated
View File

@ -362,7 +362,7 @@ dependencies = [
[[package]] [[package]]
name = "light-dm-sys" name = "light-dm-sys"
version = "0.0.1" version = "0.0.1"
source = "git+https://raatty.club:3000/raatty/lightdm-rs.git#a3c669583bb932e2b25372048b1e9dbda1f10e11" source = "git+https://git.raatty.club/raatty/lightdm-rs.git#a3c669583bb932e2b25372048b1e9dbda1f10e11"
dependencies = [ dependencies = [
"gio-sys", "gio-sys",
"glib-sys", "glib-sys",
@ -374,7 +374,7 @@ dependencies = [
[[package]] [[package]]
name = "lightdm" name = "lightdm"
version = "0.1.0" version = "0.1.0"
source = "git+https://raatty.club:3000/raatty/lightdm-rs.git#a3c669583bb932e2b25372048b1e9dbda1f10e11" source = "git+https://git.raatty.club/raatty/lightdm-rs.git#a3c669583bb932e2b25372048b1e9dbda1f10e11"
dependencies = [ dependencies = [
"gio", "gio",
"gio-sys", "gio-sys",

View File

@ -9,7 +9,7 @@ edition = "2018"
libhandy = "0.5.0" libhandy = "0.5.0"
gdk = "0.12.1" gdk = "0.12.1"
gtk = "0.8.1" gtk = "0.8.1"
lightdm = { git = "https://raatty.club:3000/raatty/lightdm-rs.git"} lightdm = { git = "https://git.raatty.club/raatty/lightdm-rs.git"}
[profile.release] [profile.release]
panic = "abort" panic = "abort"

View File

@ -14,3 +14,6 @@ lightdm.conf
greeter-session=lightdm-mobile-greeter greeter-session=lightdm-mobile-greeter
user-session=<THE CHOSEN DE TO LAUNCH AFTER SUCCESSFUL LOGIN> user-session=<THE CHOSEN DE TO LAUNCH AFTER SUCCESSFUL LOGIN>
``` ```
## Theming
If you have a file at `/etc/lightdm/lightdm_mobile_greeter.css` styling will be read from it falling back to the backed in styling, checkout style.css to get ideas on what to change

View File

@ -77,7 +77,10 @@
<child> <child>
<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

@ -5,7 +5,10 @@ use libhandy;
use lightdm; use lightdm;
use lightdm::{GreeterExt, SessionExt, UserExt, UserListExt}; use lightdm::{GreeterExt, SessionExt, UserExt, UserListExt};
use std::cell::RefCell; use std::cell::RefCell;
use std::io::prelude::*;
use std::path::*;
use std::rc::Rc; use std::rc::Rc;
use std::{fs, io};
fn main() { fn main() {
if gtk::init().is_err() { if gtk::init().is_err() {
@ -22,6 +25,16 @@ 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");
@ -86,14 +99,27 @@ fn main() {
(screen_size.height as f32 * 0.8) as i32, (screen_size.height as f32 * 0.8) as i32,
); );
let style = gtk::CssProvider::new(); let style = gtk::CssProvider::new();
let screen = gdk::Screen::get_default().expect("cant get screen");
style style
.load_from_data(include_bytes!("../style.css")) .load_from_data(include_bytes!("../style.css"))
.expect("failed to load style"); .expect("failed to load style");
gtk::StyleContext::add_provider_for_screen( gtk::StyleContext::add_provider_for_screen(
&gdk::Screen::get_default().expect("cant get screen"), &screen,
&style, &style,
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION, gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,
); );
let custom_conf = Path::new("/etc/lightdm/lightdm_mobile_greeter.css");
if custom_conf.exists() {
let style2 = gtk::CssProvider::new();
if let Some(path) = custom_conf.to_str() {
style2.load_from_path(path).expect("failed to load style2");
}
gtk::StyleContext::add_provider_for_screen(
&screen,
&style2,
gtk::STYLE_PROVIDER_PRIORITY_USER,
)
}
} }
window.show(); window.show();
gtk::main(); gtk::main();
@ -207,13 +233,30 @@ impl Handler {
} }
let keys_iter = keys.iter(); let keys_iter = keys.iter();
for (rb, key) in rbs.iter().zip(keys_iter) { for (rb, key) in rbs.iter().zip(keys_iter) {
let handler_clone = handler.clone(); let handler_clone = handler.clone();
let key_clone = key.clone(); let key_clone = key.clone();
rb.connect_toggled(move |_| { rb.connect_toggled(move |_| {
handler_clone.borrow_mut().session = Some(key_clone.clone()); handler_clone.borrow_mut().session = Some(key_clone.clone());
}); });
}; }
self.de_select.as_ref().expect("no de select").add(&vbox); self.de_select.as_ref().expect("no de select").add(&vbox);
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;
}