about summary refs log tree commit diff
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-11-13 23:46:11 -0700
committerIrene Knapp <ireneista@irenes.space>2026-11-13 23:46:11 -0700
commit1869866eb174e3a796e7ff16ab51535d8201ab95 (patch)
treeebbcb80ed025ee898e935787afdd39295dd729b9
parentc8e87126b038a5f70b7c5a0eac018c0d12486f43 (diff)
it prints a time now
no auto-update though

Force-Push: yes
Change-Id: I95804235a03540c13a42241712a42ca0704a34ea
-rw-r--r--Cargo.lock115
-rw-r--r--Cargo.toml4
-rw-r--r--src/main.rs14
3 files changed, 131 insertions, 2 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 6e41252..593a2e0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -9,6 +9,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
 
 [[package]]
+name = "deranged"
+version = "0.5.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9e9de72ce2ad1f90dc62fa25f0f430ef85eb4b0d8fa0be4f30373bc40a21d28e"
+
+[[package]]
 name = "libc"
 version = "0.2.191"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -21,12 +27,42 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
 
 [[package]]
+name = "num-conv"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441"
+
+[[package]]
+name = "num_threads"
+version = "0.1.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cabcc654086861f9e1bc5115258de62ef92c79b20f4615a1b0cc57c4e82027d4"
+dependencies = [
+ "libc",
+]
+
+[[package]]
 name = "pkg-config"
 version = "0.3.34"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548"
 
 [[package]]
+name = "powerfmt"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4a6394b9e965e73d0a289ee54f589087e2c676aedf60885baf52c76b771e4958"
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.107"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
 name = "quick-xml"
 version = "0.41.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -36,14 +72,93 @@ dependencies = [
 ]
 
 [[package]]
+name = "quote"
+version = "1.0.47"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
 name = "sandbar"
 version = "1.0.0"
 dependencies = [
+ "time",
  "x11",
  "xcb",
 ]
 
 [[package]]
+name = "serde_core"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "syn"
+version = "3.0.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "time"
+version = "0.3.55"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134"
+dependencies = [
+ "deranged",
+ "libc",
+ "num-conv",
+ "num_threads",
+ "powerfmt",
+ "serde_core",
+ "time-core",
+ "time-macros",
+]
+
+[[package]]
+name = "time-core"
+version = "0.1.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109"
+
+[[package]]
+name = "time-macros"
+version = "0.2.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7e689342a48d2ea927c87ea50cabf8594854bf940e9310208848d680d668ed85"
+dependencies = [
+ "num-conv",
+ "time-core",
+]
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
+
+[[package]]
 name = "x11"
 version = "2.21.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index 1bb85d3..2274304 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,3 +12,7 @@ features = [ "libxcb_v1_14", "xlib_xcb" ]
 version = "2.21.0"
 features = [ "xft", "xlib_xcb" ]
 
+[dependencies.time]
+version = "0.3.55"
+features = [ "local-offset", "macros", "formatting" ]
+
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(())
   }