summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--draw.c26
-rw-r--r--group.c6
-rw-r--r--group.h2
-rw-r--r--group.obin5656 -> 6016 bytes
-rw-r--r--read_cfg.c20
-rw-r--r--read_cfg.obin5160 -> 5760 bytes
6 files changed, 53 insertions, 1 deletions
diff --git a/draw.c b/draw.c
index a95d618..044a862 100644
--- a/draw.c
+++ b/draw.c
@@ -1,5 +1,6 @@
#include <ncurses.h>
#include <stdbool.h>
+#include <stdlib.h>
#include <string.h>
#include "entry.h"
#include "group.h"
@@ -15,6 +16,7 @@ char *trim_name(char *name, char *path, int max_len);
void update_entries();
void switch_col();
void trav_col(int dir); //0 = down, 1 = up
+void launch_entry();
static int width;
static int height;
@@ -100,6 +102,10 @@ int main(){
trav_col(1);
break;
+ case 10: //enter key
+ launch_entry();
+ break;
+
default:
endwin();
return 0;
@@ -256,3 +262,23 @@ void trav_col(int dir){
wrefresh(entry_win);
return;
}
+
+//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 *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, path);
+ strcat(program, "\"");
+ printf("DEBUG: program = %s\n", program);
+ system(program);
+ }
+
+ return;
+}
diff --git a/group.c b/group.c
index be2594d..7c6bc03 100644
--- a/group.c
+++ b/group.c
@@ -22,6 +22,7 @@ void group_add(char *gname, ENTRY *addme);
GROUP **get_groups();
char *get_gname(GROUP *g);
char *get_gprog(GROUP *g);
+void set_gprog(GROUP *g, char *p);
ENTRY *get_ghead(GROUP *g);
int get_ecount(GROUP *g);
int get_gcount();
@@ -128,6 +129,11 @@ char *get_gprog(GROUP *g){
return g->program;
}
+void set_gprog(GROUP *g, char *p){
+ assert(g != NULL);
+ strcpy(g->program, p);
+}
+
ENTRY *get_ghead(GROUP *g){
assert(g != NULL);
return g->head;
diff --git a/group.h b/group.h
index 01fe54d..eaebf3f 100644
--- a/group.h
+++ b/group.h
@@ -13,6 +13,8 @@ char *get_gname(GROUP *g);
char *get_gprog(GROUP *g);
+void set_gprog(GROUP *g, char *p);
+
ENTRY *get_ghead(GROUP *g);
int get_ecount(GROUP *g);
diff --git a/group.o b/group.o
index ced49ea..cb89b1c 100644
--- a/group.o
+++ b/group.o
Binary files differ
diff --git a/read_cfg.c b/read_cfg.c
index 656cba6..745c55a 100644
--- a/read_cfg.c
+++ b/read_cfg.c
@@ -62,6 +62,8 @@ void check_line(char *buffer){
char *delims = " \t\n";
char *tok = strtok(buffer, delims);
char *args[MAX_ARGS];
+ GROUP **g;
+ int g_count;
int i;
//initialize args to NULL
@@ -91,10 +93,26 @@ void check_line(char *buffer){
//create a new group
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"))){
+ 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;
+ }
+ }
+
+ //couldn't find a match
+ printf("Error: Group \"%s\" does not exist\n", args[1]);
+ }
+
return;
}
-//still needs polish in regards to wildcards, at the moment only works for something like "/home/john/Videos/*", won't work for "/home/john/Videos/*mp4"
void handle_fname(char *path, char *group){
ENTRY *new;
char *search; //pointer for traversing path
diff --git a/read_cfg.o b/read_cfg.o
index a978c2b..5bbca6b 100644
--- a/read_cfg.o
+++ b/read_cfg.o
Binary files differ