fix just mock server
This commit is contained in:
parent
cf8559e07e
commit
a29c1a9162
2 changed files with 94 additions and 55 deletions
32
README.md
32
README.md
|
|
@ -1,2 +1,34 @@
|
|||
# cosmic-greeter
|
||||
libcosmic greeter for greetd, which can be run inside cosmic-comp
|
||||
|
||||
## Development
|
||||
|
||||
This project uses [just](https://github.com/casey/just) as a command runner.
|
||||
|
||||
### Available Commands
|
||||
|
||||
#### Building
|
||||
- `just build-debug` - Compile with debug profile
|
||||
- `just build-release` - Compile with release profile (default)
|
||||
- `just build-vendored` - Compile release profile with vendored dependencies
|
||||
|
||||
#### Testing & Development
|
||||
- `just mock` - Run greeter in a windowed compositor for quick testing (builds and runs the mock server example)
|
||||
- `just run` - Run with debug logs (`RUST_LOG=debug` and `RUST_BACKTRACE=full`)
|
||||
|
||||
#### Code Quality
|
||||
- `just check` - Run clippy linter with pedantic warnings
|
||||
- `just check-json` - Run clippy with JSON output format
|
||||
|
||||
#### Installation
|
||||
- `just install` - Install all files (binary, daemon, D-Bus config, systemd files)
|
||||
- `just install-debian` - Install only Debian package required files
|
||||
- `just uninstall` - Remove all installed files
|
||||
|
||||
#### Cleanup
|
||||
- `just clean` - Run `cargo clean`
|
||||
- `just clean-dist` - Run `cargo clean` and remove vendored dependencies
|
||||
|
||||
#### Vendoring
|
||||
- `just vendor` - Vendor dependencies locally and create vendor.tar
|
||||
- `just vendor-extract` - Extract vendored dependencies from vendor.tar
|
||||
|
|
|
|||
|
|
@ -2,19 +2,21 @@ use greetd_ipc::{AuthMessageType, ErrorType, Request, Response, codec::TokioCode
|
|||
use std::{env, fs, io, thread};
|
||||
use tokio::net::UnixListener;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
fn main() {
|
||||
let greetd_sock = env::current_dir().unwrap().join("socket");
|
||||
if greetd_sock.exists() {
|
||||
fs::remove_file(&greetd_sock).unwrap();
|
||||
}
|
||||
|
||||
// Set up the socket environment variable before spawning greeter
|
||||
unsafe { env::set_var("GREETD_SOCK", &greetd_sock) };
|
||||
|
||||
// Spawn the mock greetd server in a background thread
|
||||
thread::spawn(move || {
|
||||
let rt = tokio::runtime::Runtime::new().unwrap();
|
||||
rt.block_on(async {
|
||||
let listener = UnixListener::bind(&greetd_sock).unwrap();
|
||||
println!("listening at {:?}", greetd_sock);
|
||||
unsafe { env::set_var("GREETD_SOCK", &greetd_sock) };
|
||||
thread::spawn(|| {
|
||||
cosmic_greeter::greeter::main().unwrap();
|
||||
});
|
||||
|
||||
loop {
|
||||
let (socket, _addr) = listener.accept().await.unwrap();
|
||||
|
|
@ -53,7 +55,7 @@ async fn main() {
|
|||
Some("password") => Response::Success,
|
||||
_ => Response::Error {
|
||||
error_type: ErrorType::AuthError,
|
||||
description: "pam_authenticate: AUTH_ERR".to_string(),
|
||||
description: "AUTH_ERR".to_string(),
|
||||
},
|
||||
},
|
||||
Request::StartSession { .. } => Response::Success,
|
||||
|
|
@ -65,4 +67,9 @@ async fn main() {
|
|||
socket.try_write(&bytes).unwrap();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Run greeter on main thread (required for winit event loop)
|
||||
cosmic_greeter::greeter::main().unwrap();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue