diff --git a/src/config.rs b/src/config.rs index 9cdb269..9a68072 100644 --- a/src/config.rs +++ b/src/config.rs @@ -85,6 +85,9 @@ pub struct Config { #[arg(long, action = clap::ArgAction::Set, num_args = 0..=1, default_value = "true", default_missing_value = "true")] pub show_album_art: bool, + #[arg(long, action = clap::ArgAction::Set, num_args = 0..=1, default_value = "false", default_missing_value = "true")] + pub show_keyboard_layout: bool, + #[arg(long)] pub image: Option, diff --git a/src/input.rs b/src/input.rs index 859d8d7..b70762f 100644 --- a/src/input.rs +++ b/src/input.rs @@ -102,6 +102,11 @@ impl InputHandler { /// Update timers (should be called periodically) pub fn update(&mut self) { } + + /// Get the current Caps Lock state + pub fn caps_lock(&self) -> bool { + self.caps_lock + } } /// Actions that can result from keyboard input diff --git a/src/lock.rs b/src/lock.rs index 73a93e9..68a83ca 100644 --- a/src/lock.rs +++ b/src/lock.rs @@ -107,6 +107,10 @@ impl LockedSurface { self.key_highlight_shown = false; } + // Update caps lock state in renderer + self.renderer.caps_lock = self.input_handler.caps_lock(); + log::debug!("Caps lock state: {}", self.input_handler.caps_lock()); + // Set background if available and not already applied if !self.background_applied { if let Some(ref background) = self.background { diff --git a/src/main.rs b/src/main.rs index a458bfa..a692275 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,6 @@ mod lock; mod render; mod screenshot; mod system; -mod timer; mod util; use config::Config; diff --git a/src/render.rs b/src/render.rs index 2db235a..47b0d53 100644 --- a/src/render.rs +++ b/src/render.rs @@ -21,7 +21,7 @@ pub struct Renderer { password_display: String, uptime_cache: String, last_uptime_update: Option, - caps_lock: bool, + pub caps_lock: bool, pub system_status: SystemStatus, media_art_surface: Option, last_art_url: Option, @@ -230,6 +230,10 @@ impl Renderer { self.draw_bluetooth(); } + if self.config.show_keyboard_layout { + self.draw_keyboard_layout(); + } + if !self.password_display.is_empty() { self.draw_password_display(); } @@ -703,6 +707,21 @@ impl Renderer { } } + fn draw_keyboard_layout(&self) { + if let Some(layout) = self.system_status.keyboard_layout { + let margin = 20.0; + let x = margin; + let y = margin + 80.0; + + self.context.new_path(); + self.context.set_source_rgba(1.0, 1.0, 1.0, self.fade_alpha); + self.context.set_font_size(16.0); + let text = format!("Layout: {}", layout); + self.context.move_to(x, y); + self.context.show_text(&text).unwrap(); + } + } + fn draw_icon_at(&self, x: f64, y: f64, surface: &ImageSurface) { self.context.save().unwrap(); let target_size = 24.0;