Browse Source

Conf: Add [misc] status_path option to choose status script path

Martin Duquesnoy 14 years ago
parent
commit
c5da009b7a
6 changed files with 21 additions and 17 deletions
  1. 1 0
      src/config.c
  2. 1 1
      src/event.c
  3. 16 14
      src/init.c
  4. 1 0
      src/structs.h
  5. 1 1
      src/wmfs.c
  6. 1 1
      src/wmfs.h

+ 1 - 0
src/config.c

@@ -145,6 +145,7 @@ conf_misc_section(char *src)
      conf.raiseswitch   = get_opt(src, "false", "raiseswitch").bool;
      conf.focus_fmouse  = get_opt(src, "true", "focus_follow_mouse").bool;
      conf.status_timing = get_opt(src, "1", "status_timing").num;
+     conf.status_path   = get_opt(src, "", "status_path").str;
      pad                = get_opt(src, "12", "pad").num;
 
      if(pad > 24 || pad < 1)

+ 1 - 1
src/event.c

@@ -235,7 +235,7 @@ clientmessageevent(XClientMessageEvent *ev)
 
      if(mess_t == wmfs_update_status
                && estatus)
-          spawn(status_path);
+          spawn(conf.status_path);
 
      return;
 }

+ 16 - 14
src/init.c

@@ -184,36 +184,38 @@ init_status(void)
      struct stat st;
      char *home;
 
-     if(!(home = getenv("HOME")))
+     if(!conf.status_path)
      {
-          warnx("HOME not set, can't launch status.sh");
-          estatus = False;
-          return;
-     }
+          if(!(home = getenv("HOME")))
+          {
+               warnx("HOME not set, can't launch status.sh");
+               estatus = False;
+               return;
+          }
 
-     status_path = emalloc(strlen(home) + strlen(DEF_STATUS) + 2, sizeof(char));
+          conf.status_path = emalloc(strlen(home) + strlen(DEF_STATUS) + 2, sizeof(char));
 
-     sprintf(status_path, "%s/"DEF_STATUS, home);
+          sprintf(conf.status_path, "%s/"DEF_STATUS, home);
+     }
 
-     if(!(fd = open(status_path, O_RDONLY))
-               || !fopen(status_path, "r"))
+     if(!(fd = open(conf.status_path, O_RDONLY))
+               || !fopen(conf.status_path, "r"))
      {
-          free(status_path);
+          free(conf.status_path);
           estatus = False;
 
           return;
      }
 
-     stat(status_path, &st);
+     stat(conf.status_path, &st);
 
      if(st.st_size && st.st_mode & S_IXUSR)
      {
           estatus = True;
-          spawn(status_path);
+          spawn(conf.status_path);
      }
      else
-          warnx("status.sh file present in wmfs directory can't be executed, try 'chmod +x %s'.",
-                    status_path);
+          warnx("status file specified in configuratin (status_path) or present in wmfs directory can't be executed, try 'chmod +x %s'.", conf.status_path);
 
      close(fd);
 

+ 1 - 0
src/structs.h

@@ -325,6 +325,7 @@ typedef struct
      Bool focus_fmouse;
      uint pad;
      int status_timing;
+     char *status_path;
      struct
      {
           /*

+ 1 - 1
src/wmfs.c

@@ -154,7 +154,7 @@ thread_process(void *arg)
      {
           while(!exiting)
           {
-               spawn(status_path);
+               spawn(conf.status_path);
                sleep(conf.status_timing);
           }
 

+ 1 - 1
src/wmfs.h

@@ -369,7 +369,7 @@ Bool exiting, estatus;
 XRectangle *sgeo;
 XRectangle *spgeo;
 Cursor cursor[CurLast];
-char *argv_global, *status_path;
+char *argv_global;
 int xrandr_event;
 uint timing;