diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index aa0eb0c..0276a45 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,8 @@ use crate::x::*; use std::sync::Arc; +use time::OffsetDateTime; +use time::format_description::{ FormatDescriptionV3, parse_owned }; use xcb::{ Xid }; use xcb::x::{ ClientMessageData, @@ -36,6 +38,7 @@ struct Dock { bounds: Arc<Rectangle<u16>>, font: Arc<Font>, baseline_position: i16, + time_format: FormatDescriptionV3<'static>, } impl HasWindow for Dock { @@ -122,11 +125,17 @@ impl Dock { + vertical_padding as i16 + configuration.baseline_offset as i16; + let time_format_string = + "[weekday repr:short] [year]-[month]-[day] ".to_owned() + + "[hour repr:24]:[minute]:[second]"; + let time_format = parse_owned::<3>(&time_format_string).unwrap(); + let dock = Dock { window, configuration, bounds: Arc::new(dock_bounds), font, - baseline_position + baseline_position, + time_format, }; dock.set_string_property(&xcb::x::ATOM_WM_NAME, b"sandbar")?; @@ -233,7 +242,8 @@ impl Dock { } self.draw_text("playful cool fic tech nonfic", Alignment::Left)?; - self.draw_text("2026", Alignment::Right)?; + let time = OffsetDateTime::now_local().unwrap(); + self.draw_text(&time.format(&self.time_format).unwrap(), Alignment::Right)?; Ok(()) } |