sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dmenu-date-5.2.diff (1494B)


      1 From 64fb38e3778addc0272eb8793deb909e639e5746 Mon Sep 17 00:00:00 2001
      2 From: piotr-marendowski <piotr-marendowski@tutanota.com>
      3 Date: Thu, 6 Jul 2023 10:03:03 +0000
      4 Subject: [PATCH] Displays date and time at the bottom of the vertical layout.
      5 
      6 ---
      7  dmenu.c | 20 +++++++++++++++++++-
      8  1 file changed, 19 insertions(+), 1 deletion(-)
      9 
     10 diff --git a/dmenu.c b/dmenu.c
     11 index 7cf253b..5428f67 100644
     12 --- a/dmenu.c
     13 +++ b/dmenu.c
     14 @@ -84,7 +84,7 @@ calcoffsets(void)
     15  	int i, n;
     16  
     17  	if (lines > 0)
     18 -		n = lines * bh;
     19 +		n = (lines * bh) - 1;
     20  	else
     21  		n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">"));
     22  	/* calculate which items will begin the next page and previous page */
     23 @@ -143,6 +143,22 @@ drawitem(struct item *item, int x, int y, int w)
     24  	return drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
     25  }
     26  
     27 +static int
     28 +drawdate(int x, int y, int w)
     29 +{
     30 +    char date[128];
     31 +    time_t t = time(NULL);
     32 +    struct tm *tm = localtime(&t);
     33 +
     34 +    /* Hour:Minute DayOfTheWeek DayOfTheMonth Month Year */
     35 +    strftime(date, sizeof(date), "%H:%M %A %d %B %Y", tm);
     36 +
     37 +	drw_setscheme(drw, scheme[SchemeSel]);
     38 +
     39 +	int r = drw_text(drw, x, y, w, bh, lrpad / 2, date, 0);
     40 +	return r;
     41 +}
     42 +
     43  static void
     44  drawmenu(void)
     45  {
     46 @@ -172,6 +188,8 @@ drawmenu(void)
     47  		/* draw vertical list */
     48  		for (item = curr; item != next; item = item->right)
     49  			drawitem(item, x, y += bh, mw - x);
     50 +
     51 +        drawdate(x, lines * bh, w);
     52  	} else if (matches) {
     53  		/* draw horizontal list */
     54  		x += inputw;
     55 -- 
     56 2.41.0
     57