diff options
author | louie <lshprung@yahoo.com> | 2020-06-26 17:26:04 -0700 |
---|---|---|
committer | louie <lshprung@yahoo.com> | 2020-06-26 17:26:04 -0700 |
commit | 7985c945cf11c50559daa8bdb03f9a023deb2da3 (patch) | |
tree | 05551b47e2b976a84b90df1cbe1c3727ab232839 | |
parent | f41dcb2b06bb379ff47a9f66cf509426706567f9 (diff) |
Basic ability to launch entries
-rw-r--r-- | draw.c | 26 | ||||
-rw-r--r-- | group.c | 6 | ||||
-rw-r--r-- | group.h | 2 | ||||
-rw-r--r-- | group.o | bin | 5656 -> 6016 bytes | |||
-rw-r--r-- | read_cfg.c | 20 | ||||
-rw-r--r-- | read_cfg.o | bin | 5160 -> 5760 bytes |
6 files changed, 53 insertions, 1 deletions
@@ -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; +} @@ -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; @@ -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); Binary files differ@@ -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 Binary files differ |