diff options
author | louie <lshprung@yahoo.com> | 2020-06-27 10:31:53 -0700 |
---|---|---|
committer | louie <lshprung@yahoo.com> | 2020-06-27 10:31:53 -0700 |
commit | 7b9771701e55592d9aeffaa78fe827ff73ef65ac (patch) | |
tree | 8537b4e6cdcad60887337b54ee4ee46b8e640520 | |
parent | 0eb46442f5541f365ebb327375b9e5992194fbd8 (diff) |
Added ability to set flags in config
-rw-r--r-- | draw.c | 10 | ||||
-rw-r--r-- | entry.c | 2 | ||||
-rw-r--r-- | entry.o | bin | 4064 -> 3888 bytes | |||
-rw-r--r-- | group.c | 15 | ||||
-rw-r--r-- | group.h | 4 | ||||
-rw-r--r-- | group.o | bin | 6016 -> 6704 bytes | |||
-rw-r--r-- | read_cfg.c | 22 | ||||
-rw-r--r-- | read_cfg.o | bin | 6320 -> 6536 bytes |
8 files changed, 40 insertions, 13 deletions
@@ -266,17 +266,21 @@ void trav_col(int dir){ //TODO add ability to use arguments with launcher programs (like -f for fullscreen and such) void launch_entry(){ char *program = get_gprog(g[g_hover]); + char *flags = get_gflags(g[g_hover]); char *path = get_epath(e[e_hover]); //if the entry is an executable file (doesn't have a launcher) if(!(strcmp(program, "./"))) system(path); else{ - strcat(program, " "); - strcat(program, "\""); + strcat(program, " \""); + if(flags[0] !='\0'){ + strcat(program, flags); + strcat(program, "\""); + strcat(program, " \""); + } strcat(program, path); strcat(program, "\""); - printf("DEBUG: program = %s\n", program); system(program); } @@ -42,8 +42,6 @@ ENTRY *create_entry(char *new_name, char *new_path){ strcpy(new->name, new_name); strcpy(new->path, adjusted_path); - printf("1 DEBUG: %s\n", adjusted_path); - printf("2 DEBUG: %s\n", adjusted_path); new->next = NULL; return new; Binary files differ@@ -11,6 +11,7 @@ typedef struct group{ char name[BUF_LEN]; char program[BUF_LEN]; + char flags[BUF_LEN]; struct entry *head; struct entry *tail; struct group *next; @@ -23,6 +24,8 @@ GROUP **get_groups(); char *get_gname(GROUP *g); char *get_gprog(GROUP *g); void set_gprog(GROUP *g, char *p); +char *get_gflags(GROUP *g); +void set_gflags(GROUP *g, char *p); ENTRY *get_ghead(GROUP *g); int get_ecount(GROUP *g); int get_gcount(); @@ -38,6 +41,7 @@ GROUP *create_group(char *new_name){ strcpy(new->name, new_name); //by default, group name is equivalent to the path strcpy(new->program, "./"); //by default, launch an entry by executing it + new->flags[0] = '\0'; //by default, no command line flags new->head = NULL; new->tail = NULL; new->next = NULL; @@ -132,6 +136,17 @@ char *get_gprog(GROUP *g){ void set_gprog(GROUP *g, char *p){ assert(g != NULL); strcpy(g->program, p); + return; +} + +char *get_gflags(GROUP *g){ + assert(g != NULL); + return g->flags; +} + +void set_gflags(GROUP *g, char *p){ + assert(g != NULL); + strcpy(g->flags, p); } ENTRY *get_ghead(GROUP *g){ @@ -15,6 +15,10 @@ char *get_gprog(GROUP *g); void set_gprog(GROUP *g, char *p); +char *get_gflags(GROUP *g); + +void set_gflags(GROUP *g, char *p); + ENTRY *get_ghead(GROUP *g); int get_ecount(GROUP *g); Binary files differ@@ -100,23 +100,29 @@ void check_line(char *buffer){ if(!(strcmp(args[0], "add"))) handle_fname(args[1], args[2]); //create a new group - if(!(strcmp(args[0], "addGroup"))) group_add(args[1], NULL); + else if(!(strcmp(args[0], "addGroup"))) group_add(args[1], NULL); - //set a group's launcher (this requires pulling down the existing groups and finding the one that args[1] mentions) - if(!(strcmp(args[0], "setLauncher"))){ + else{ + //remaining possibilities involve args[1] being a char* referring to a group g = get_groups(); g_count = get_gcount(); //look for matching existing group for(i = 0; i < g_count; i++){ - if(!(strcmp(get_gname(g[i]), args[1]))){ - set_gprog(g[i], args[2]); - return; - } + if(!(strcmp(get_gname(g[i]), args[1]))) break; + } + + //assert that a matching group was found + if(i < g_count){ + //set a group's launcher (this requires pulling down the existing groups and finding the one that args[1] mentions) + if(!(strcmp(args[0], "setLauncher"))) set_gprog(g[i], args[2]); + + //set a group's launcher flags (like ./program -f file for fullscreen) + if(!(strcmp(args[0], "setFlags"))) set_gflags(g[i], args[2]); } //couldn't find a match - printf("Error: Group \"%s\" does not exist\n", args[1]); + else printf("Error: Group \"%s\" does not exist\n", args[1]); } return; Binary files differ |