mirror of
https://github.com/apognu/tuigreet.git
synced 2024-11-25 09:43:57 +03:00
Caps lock indicator now respects window padding.
This commit is contained in:
parent
05526ff0ba
commit
d5a700812c
14
src/info.rs
14
src/info.rs
@ -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()
|
||||
}
|
||||
|
@ -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(),
|
||||
|
Loading…
Reference in New Issue
Block a user