[wiki] [sites] [dmenu][patch][date] Add date patch || piotr-marendowski

From: <git_AT_suckless.org>
Date: Thu, 06 Jul 2023 12:13:36 +0200

commit 8053764526d97c27e38f49885572ac9be6e84e22
Author: piotr-marendowski <piotr-marendowski_AT_tutanota.com>
Date: Thu Jul 6 10:13:06 2023 +0000

    [dmenu][patch][date] Add date patch

diff --git a/tools.suckless.org/dmenu/patches/date/README.md b/tools.suckless.org/dmenu/patches/date/README.md
new file mode 100644
index 00000000..b9ca654f
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/date/README.md
_AT_@ -0,0 +1,17 @@
+date
+=============
+
+Description
+-----------
+This patch adds date and time at the bottom of the vertical dmenu layout.
+
+![dmenu date screenshot](dmenu-date.png)
+
+Download
+--------
+[dmenu-date-5.2.diff](dmenu-date-5.2.diff) (2023-07-05)
+
+Authors
+-------
+* Piotr Marendowski <piotr-marendowski_AT_tutanota.com>
+
diff --git a/tools.suckless.org/dmenu/patches/date/dmenu-date-5.2.diff b/tools.suckless.org/dmenu/patches/date/dmenu-date-5.2.diff
new file mode 100644
index 00000000..a46db90c
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/date/dmenu-date-5.2.diff
_AT_@ -0,0 +1,57 @@
+From 64fb38e3778addc0272eb8793deb909e639e5746 Mon Sep 17 00:00:00 2001
+From: piotr-marendowski <piotr-marendowski_AT_tutanota.com>
+Date: Thu, 6 Jul 2023 10:03:03 +0000
+Subject: [PATCH] Displays date and time at the bottom of the vertical layout.
+
+---
+ dmenu.c | 20 +++++++++++++++++++-
+ 1 file changed, 19 insertions(+), 1 deletion(-)
+
+diff --git a/dmenu.c b/dmenu.c
+index 7cf253b..5428f67 100644
+--- a/dmenu.c
++++ b/dmenu.c
+_AT_@ -84,7 +84,7 @@ calcoffsets(void)
+ int i, n;
+
+ if (lines > 0)
+- n = lines * bh;
++ n = (lines * bh) - 1;
+ else
+ n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">"));
+ /* calculate which items will begin the next page and previous page */
+_AT_@ -143,6 +143,22 @@ drawitem(struct item *item, int x, int y, int w)
+ return drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
+ }
+
++static int
++drawdate(int x, int y, int w)
++{
++ char date[128];
++ time_t t = time(NULL);
++ struct tm *tm = localtime(&t);
++
++ /* Hour:Minute DayOfTheWeek DayOfTheMonth Month Year */
++ strftime(date, sizeof(date), "%H:%M %A %d %B %Y", tm);
++
++ drw_setscheme(drw, scheme[SchemeSel]);
++
++ int r = drw_text(drw, x, y, w, bh, lrpad / 2, date, 0);
++ return r;
++}
++
+ static void
+ drawmenu(void)
+ {
+_AT_@ -172,6 +188,8 @@ drawmenu(void)
+ /* draw vertical list */
+ for (item = curr; item != next; item = item->right)
+ drawitem(item, x, y += bh, mw - x);
++
++ drawdate(x, lines * bh, w);
+ } else if (matches) {
+ /* draw horizontal list */
+ x += inputw;
+--
+2.41.0
+
diff --git a/tools.suckless.org/dmenu/patches/date/dmenu-date.png b/tools.suckless.org/dmenu/patches/date/dmenu-date.png
new file mode 100644
index 00000000..45a39d27
Binary files /dev/null and b/tools.suckless.org/dmenu/patches/date/dmenu-date.png differ
Received on Thu Jul 06 2023 - 12:13:36 CEST

This archive was generated by hypermail 2.3.0 : Thu Jul 06 2023 - 12:24:53 CEST