From 7985c945cf11c50559daa8bdb03f9a023deb2da3 Mon Sep 17 00:00:00 2001 From: louie Date: Fri, 26 Jun 2020 17:26:04 -0700 Subject: Basic ability to launch entries --- draw.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'draw.c') diff --git a/draw.c b/draw.c index a95d618..044a862 100644 --- a/draw.c +++ b/draw.c @@ -1,5 +1,6 @@ #include #include +#include #include #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; +} -- cgit