sites

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

dwm-logging-6.4-20230814-17c7c0a.diff (2062B)


      1 From 17c7c0ae9713c782eb032a4be67a42311269059a Mon Sep 17 00:00:00 2001
      2 From: fami fish <19bors.steriann@gmail.com>
      3 Date: Mon, 14 Aug 2023 22:23:51 +0300
      4 Subject: [PATCH] dwm-logging-6.4
      5 
      6 ---
      7  config.def.h |  3 +++
      8  dwm.c        | 22 ++++++++++++++++++++++
      9  2 files changed, 25 insertions(+)
     10 
     11 diff --git a/config.def.h b/config.def.h
     12 index 9efa774..f86ab67 100644
     13 --- a/config.def.h
     14 +++ b/config.def.h
     15 @@ -1,5 +1,8 @@
     16  /* See LICENSE file for copyright and license details. */
     17  
     18 +/* logging & debugging */
     19 +static const unsigned int logfile        = 1;   /* 1 means enable logging to a file*/    
     20 +
     21  /* appearance */
     22  static const unsigned int borderpx  = 1;        /* border pixel of windows */
     23  static const unsigned int snap      = 32;       /* snap pixel */
     24 diff --git a/dwm.c b/dwm.c
     25 index f1d86b2..d0f6db7 100644
     26 --- a/dwm.c
     27 +++ b/dwm.c
     28 @@ -25,6 +25,7 @@
     29  #include <signal.h>
     30  #include <stdarg.h>
     31  #include <stdio.h>
     32 +#include <time.h>
     33  #include <stdlib.h>
     34  #include <string.h>
     35  #include <unistd.h>
     36 @@ -222,6 +223,7 @@ static void updateclientlist(void);
     37  static int updategeom(void);
     38  static void updatenumlockmask(void);
     39  static void updatesizehints(Client *c);
     40 +static void logstr(char *c);
     41  static void updatestatus(void);
     42  static void updatetitle(Client *c);
     43  static void updatewindowtype(Client *c);
     44 @@ -2001,6 +2003,24 @@ updatesizehints(Client *c)
     45  	c->isfixed = (c->maxw && c->maxh && c->maxw == c->minw && c->maxh == c->minh);
     46  	c->hintsvalid = 1;
     47  }
     48 +void 
     49 +logstr(char* c) {
     50 +    FILE *f;
     51 +    time_t now;
     52 +    struct tm tm;
     53 +
     54 +    f = fopen("dwm.log", "a+");
     55 +    setbuf(f, NULL); /* disables buffering */
     56 +    if (f == NULL) { 
     57 +        return;
     58 +    }
     59 +    
     60 +    now = time(NULL);
     61 +    tm = *localtime(&now);
     62 +
     63 +    fprintf(f, "[%02d:%02d:%02d] %s", tm.tm_hour, tm.tm_min, tm.tm_sec, c);
     64 +    return;
     65 +}
     66  
     67  void
     68  updatestatus(void)
     69 @@ -2143,6 +2163,8 @@ zoom(const Arg *arg)
     70  int
     71  main(int argc, char *argv[])
     72  {
     73 +    logstr("DWM started");
     74 +
     75  	if (argc == 2 && !strcmp("-v", argv[1]))
     76  		die("dwm-"VERSION);
     77  	else if (argc != 1)
     78 -- 
     79 2.41.0
     80