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 /draw.c | |
parent | f41dcb2b06bb379ff47a9f66cf509426706567f9 (diff) |
Basic ability to launch entries
Diffstat (limited to 'draw.c')
-rw-r--r-- | draw.c | 26 |
1 files changed, 26 insertions, 0 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; +} |