summaryrefslogtreecommitdiff
path: root/draw.c
diff options
context:
space:
mode:
authorlouie <lshprung@yahoo.com>2020-07-01 17:40:02 -0700
committerlouie <lshprung@yahoo.com>2020-07-01 17:40:02 -0700
commit7e8fc4779554ebee40aca0de544c7409e4f75bd9 (patch)
tree60910ddcef14df2508faf3771f0d33b856ccc765 /draw.c
parenta0e2638287b718768eed2e9dcdf64cb617d37b14 (diff)
Added support for WSL
Diffstat (limited to 'draw.c')
-rw-r--r--draw.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/draw.c b/draw.c
index d4aa51a..fe41aa7 100644
--- a/draw.c
+++ b/draw.c
@@ -17,6 +17,7 @@ void update_entries();
void switch_col();
void trav_col(int dir); //0 = down, 1 = up
void launch_entry();
+char *compat_convert(char *path, int mode);
static int width;
static int height;
@@ -263,16 +264,17 @@ void trav_col(int dir){
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 *flags = get_gflags(g[g_hover]);
char *path = get_epath(e[e_hover]);
+ int mode = get_compmode();
//if the entry is an executable file (doesn't have a launcher)
if(!(strcmp(program, "./"))) system(path);
else{
+ if(mode != 0) path = compat_convert(path, mode);
strcat(program, " \"");
if(flags[0] !='\0'){
strcat(program, flags);
@@ -286,3 +288,31 @@ void launch_entry(){
return;
}
+
+char *compat_convert(char *path, int mode){
+ char *new = malloc(sizeof(char) * BUF_LEN);
+ char *trav = new;
+
+ //1 -> WSL: letter is in /mnt/, convert slashes to backslashes
+ if(mode == 1){
+ path = path+5;
+ *trav = *path - 32; //point at letter, make it uppercase
+ trav++;
+ *trav = ':';
+ path++;
+ trav++;
+
+ //convert each character
+ while(*path != '\0'){
+ if(*path == '/') *trav = '\\';
+ else *trav = *path;
+ path++;
+ trav++;
+ }
+ *trav = '\0';
+ }
+
+ else printf("Error: mode should not be %d\n", mode);
+
+ return new;
+}