Caps lock indicator now respects window padding.

This commit is contained in:
Antoine POPINEAU 2021-10-13 14:24:07 +02:00
parent 05526ff0ba
commit d5a700812c
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
2 changed files with 9 additions and 11 deletions

View File

@ -3,7 +3,7 @@ use std::{
error::Error,
fs, io,
path::{Path, PathBuf},
process::{Command, Output},
process::Command,
};
use ini::Ini;
@ -86,15 +86,11 @@ where
}
pub fn capslock_status() -> bool {
match command("kbdinfo", &["gkbled", "capslock"]) {
let mut command = Command::new("kbdinfo");
command.args(["gkbled", "capslock"]);
match command.output() {
Ok(output) => output.status.code() == Some(0),
Err(_) => false,
}
}
pub fn command<S>(name: S, args: &[&str]) -> io::Result<Output>
where
S: Into<String>,
{
Command::new(name.into()).args(args).output()
}

View File

@ -72,13 +72,15 @@ pub async fn draw(greeter: Arc<RwLock<Greeter>>, terminal: &mut Term) -> Result<
f.render_widget(time, chunks[TITLEBAR_INDEX]);
}
let status_block_size = (size.width - (2 * greeter.window_padding())) / 2;
let status_chunks = Layout::default()
.direction(Direction::Horizontal)
.constraints(
[
Constraint::Length(greeter.window_padding()),
Constraint::Percentage(50),
Constraint::Percentage(50),
Constraint::Length(status_block_size),
Constraint::Length(status_block_size),
Constraint::Length(greeter.window_padding()),
]
.as_ref(),