Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
e543c2c9be | |||
4333ea81a5 | |||
ce4a58c82b | |||
37040526b9 | |||
175e47aca5 | |||
3428668049 | |||
93f34bac63 | |||
7817439629 |
136
Cargo.lock
generated
136
Cargo.lock
generated
@@ -1,5 +1,16 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.7.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atk"
|
||||
version = "0.8.0"
|
||||
@@ -26,6 +37,17 @@ dependencies = [
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.2.1"
|
||||
@@ -63,6 +85,25 @@ version = "1.0.52"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3d87b23d6a92cd03af510a5ade527033f6aa6fa92161e2d5863a907d4c5e31d"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c90bf5f19754d10198ccb95b70664fc925bd1fc090a0fd9a6ebc54acc8cd6272"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"humantime",
|
||||
"log",
|
||||
"regex",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-channel"
|
||||
version = "0.3.4"
|
||||
@@ -307,6 +348,21 @@ dependencies = [
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
@@ -362,7 +418,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "light-dm-sys"
|
||||
version = "0.0.1"
|
||||
source = "git+https://raatty.club:3000/raatty/lightdm-rs.git#a3c669583bb932e2b25372048b1e9dbda1f10e11"
|
||||
source = "git+https://git.uninsane.org/colin/lightdm-rs.git#4323e3244dff086a8120bfd93240cb9c28a308c8"
|
||||
dependencies = [
|
||||
"gio-sys",
|
||||
"glib-sys",
|
||||
@@ -374,7 +430,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "lightdm"
|
||||
version = "0.1.0"
|
||||
source = "git+https://raatty.club:3000/raatty/lightdm-rs.git#a3c669583bb932e2b25372048b1e9dbda1f10e11"
|
||||
source = "git+https://git.uninsane.org/colin/lightdm-rs.git#4323e3244dff086a8120bfd93240cb9c28a308c8"
|
||||
dependencies = [
|
||||
"gio",
|
||||
"gio-sys",
|
||||
@@ -388,14 +444,31 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lightdm-mobile-greeter"
|
||||
version = "0.1.0"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"env_logger",
|
||||
"gdk",
|
||||
"gtk",
|
||||
"libhandy",
|
||||
"lightdm",
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.3.1"
|
||||
@@ -471,6 +544,23 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244"
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.2"
|
||||
@@ -488,8 +578,48 @@ dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
10
Cargo.toml
10
Cargo.toml
@@ -1,15 +1,17 @@
|
||||
[package]
|
||||
name = "lightdm-mobile-greeter"
|
||||
version = "0.1.0"
|
||||
authors = ["Raatty <me@raatty.club>"]
|
||||
version = "0.1.2"
|
||||
authors = ["Raatty <me@raatty.club>", "Colin <colin@uninsane.org>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
[dependencies]
|
||||
libhandy = "0.5.0"
|
||||
env_logger = "0.9"
|
||||
gdk = "0.12.1"
|
||||
gtk = "0.8.1"
|
||||
lightdm = { git = "https://git.raatty.club/raatty/lightdm-rs.git"}
|
||||
libhandy = "0.5.0"
|
||||
lightdm = { git = "https://git.uninsane.org/colin/lightdm-rs.git"}
|
||||
log = "0.4"
|
||||
|
||||
[profile.release]
|
||||
panic = "abort"
|
||||
|
42
flake.lock
generated
Normal file
42
flake.lock
generated
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1659877975,
|
||||
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1666164185,
|
||||
"narHash": "sha256-5v+YB4ijeUfg5LCz9ck4gIpCPhIS+qn02OyPJO48bCE=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "c5203abb1329f7ea084c04acda330ca75d5b9fb5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixos-22.05",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
51
flake.nix
Normal file
51
flake.nix
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
description = "A simple log in screen for use on touch screens.";
|
||||
inputs = {
|
||||
nixpkgs.url = "nixpkgs/nixos-22.05";
|
||||
flake-utils.url = github:numtide/flake-utils;
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
with flake-utils.lib; eachSystem allSystems (system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
buildInputs = with pkgs; [ gtk3 libhandy_0 lightdm ];
|
||||
nativeBuildInputs = with pkgs; [ ];
|
||||
in
|
||||
rec {
|
||||
packages = {
|
||||
# docs: <nixpkgs>/doc/languages-frameworks/rust.section.md
|
||||
# docs: https://github.com/oxalica/rust-overlay
|
||||
lightdm-mobile-greeter = pkgs.rustPlatform.buildRustPackage {
|
||||
pname = "lightdm-mobile-greeter";
|
||||
version = "0.1.1";
|
||||
|
||||
src = ./.;
|
||||
cargoLock = {
|
||||
lockFile = ./Cargo.lock;
|
||||
outputHashes = {
|
||||
"light-dm-sys-0.0.1" = "sha256-5o/DZqP6j6xRwf+YmrtQTpcg4PhTvQ0hKC1WauLdqzc=";
|
||||
};
|
||||
};
|
||||
|
||||
inherit buildInputs nativeBuildInputs;
|
||||
|
||||
postInstall = ''
|
||||
mkdir -p $out/share/applications
|
||||
substitute lightdm-mobile-greeter.desktop \
|
||||
$out/share/applications/lightdm-mobile-greeter.desktop \
|
||||
--replace lightdm-mobile-greeter $out/bin/lightdm-mobile-greeter
|
||||
'';
|
||||
};
|
||||
};
|
||||
defaultPackage = packages.lightdm-mobile-greeter;
|
||||
|
||||
devShells.default = with pkgs; mkShell {
|
||||
# Allow cargo to download crates.
|
||||
SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";
|
||||
|
||||
# include both build and runtime deps in the shell so once can build and run the result.
|
||||
buildInputs = buildInputs ++ nativeBuildInputs ++ [ cargo ];
|
||||
};
|
||||
});
|
||||
}
|
29
src/main.rs
29
src/main.rs
@@ -1,20 +1,31 @@
|
||||
use env_logger;
|
||||
use gdk;
|
||||
use gtk;
|
||||
use gtk::prelude::*;
|
||||
use gtk;
|
||||
use libhandy;
|
||||
use lightdm;
|
||||
use lightdm::{GreeterExt, SessionExt, UserExt, UserListExt};
|
||||
use lightdm;
|
||||
use log;
|
||||
use std::cell::RefCell;
|
||||
use std::io::prelude::*;
|
||||
use std::path::*;
|
||||
use std::rc::Rc;
|
||||
use std::{fs, io};
|
||||
|
||||
fn init_logging() {
|
||||
let conf = env_logger::Env::new().default_filter_or("INFO");
|
||||
env_logger::Builder::from_env(conf).init();
|
||||
log::info!("logging initialized");
|
||||
}
|
||||
|
||||
fn main() {
|
||||
init_logging();
|
||||
|
||||
if gtk::init().is_err() {
|
||||
println!("failed to init GTK");
|
||||
log::error!("failed to init GTK");
|
||||
return;
|
||||
}
|
||||
|
||||
libhandy::Keypad::new(true, true);
|
||||
let builder = gtk::Builder::new_from_string(include_str!("../interface.ui"));
|
||||
let handler = Rc::new(RefCell::new(Handler::new()));
|
||||
@@ -149,9 +160,15 @@ impl Handler {
|
||||
|
||||
fn set_username(&mut self) {
|
||||
if let Some(user_list) = lightdm::UserList::get_instance() {
|
||||
if let Some(name) = user_list.get_users().first().unwrap().get_name() {
|
||||
match user_list.get_users().first() {
|
||||
Some(user) => match user.get_name() {
|
||||
Some(name) => {
|
||||
let name_str = Box::<str>::from(name);
|
||||
self.user = Some(String::from(name_str));
|
||||
},
|
||||
None => log::warn!("user.get_name() returned None"),
|
||||
},
|
||||
None => log::warn!("user_list.get_users() returned empty"),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -163,11 +180,11 @@ impl Handler {
|
||||
let handler_borrowed = handler_auth_clone.borrow();
|
||||
if greeter.get_is_authenticated() {
|
||||
greeter
|
||||
.start_session_sync(Some(&handler_borrowed.session.clone().unwrap()))
|
||||
.start_session_sync(Some(&handler_borrowed.session.clone().expect("auth handler.session is None")))
|
||||
.ok();
|
||||
} else {
|
||||
greeter
|
||||
.authenticate(Some(&handler_borrowed.user.clone().unwrap()))
|
||||
.authenticate(Some(&handler_borrowed.user.clone().expect("auth handler.user is None")))
|
||||
.ok();
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user