diff options
| author | Irene Knapp <ireneista@irenes.space> | 2026-11-13 23:46:11 -0700 |
|---|---|---|
| committer | Irene Knapp <ireneista@irenes.space> | 2026-11-13 23:46:11 -0700 |
| commit | 1869866eb174e3a796e7ff16ab51535d8201ab95 (patch) | |
| tree | ebbcb80ed025ee898e935787afdd39295dd729b9 /src/main.rs | |
| parent | c8e87126b038a5f70b7c5a0eac018c0d12486f43 (diff) | |
it prints a time now
no auto-update though Force-Push: yes Change-Id: I95804235a03540c13a42241712a42ca0704a34ea
Diffstat (limited to 'src/main.rs')
| -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(()) } |