summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlouie <lshprung@yahoo.com>2020-06-27 10:31:53 -0700
committerlouie <lshprung@yahoo.com>2020-06-27 10:31:53 -0700
commit7b9771701e55592d9aeffaa78fe827ff73ef65ac (patch)
tree8537b4e6cdcad60887337b54ee4ee46b8e640520
parent0eb46442f5541f365ebb327375b9e5992194fbd8 (diff)
Added ability to set flags in config
-rw-r--r--draw.c10
-rw-r--r--entry.c2
-rw-r--r--entry.obin4064 -> 3888 bytes
-rw-r--r--group.c15
-rw-r--r--group.h4
-rw-r--r--group.obin6016 -> 6704 bytes
-rw-r--r--read_cfg.c22
-rw-r--r--read_cfg.obin6320 -> 6536 bytes
8 files changed, 40 insertions, 13 deletions
diff --git a/draw.c b/draw.c
index 044a862..d4aa51a 100644
--- a/draw.c
+++ b/draw.c
@@ -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);
}
diff --git a/entry.c b/entry.c
index f9647f5..46cb6b4 100644
--- a/entry.c
+++ b/entry.c
@@ -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;
diff --git a/entry.o b/entry.o
index 4b56b98..83836f3 100644
--- a/entry.o
+++ b/entry.o
Binary files differ
diff --git a/group.c b/group.c
index 7c6bc03..9c1736c 100644
--- a/group.c
+++ b/group.c
@@ -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){
diff --git a/group.h b/group.h
index eaebf3f..2dc18b9 100644
--- a/group.h
+++ b/group.h
@@ -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);
diff --git a/group.o b/group.o
index cb89b1c..e3c006f 100644
--- a/group.o
+++ b/group.o
Binary files differ
diff --git a/read_cfg.c b/read_cfg.c
index 51572c1..d18685b 100644
--- a/read_cfg.c
+++ b/read_cfg.c
@@ -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;
diff --git a/read_cfg.o b/read_cfg.o
index fd942a8..19871bf 100644
--- a/read_cfg.o
+++ b/read_cfg.o
Binary files differ