aboutsummaryrefslogtreecommitdiff
path: root/src/wine.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/wine.c')
-rw-r--r--src/wine.c83
1 files changed, 80 insertions, 3 deletions
diff --git a/src/wine.c b/src/wine.c
index 9a249b1..fa65ebc 100644
--- a/src/wine.c
+++ b/src/wine.c
@@ -19,10 +19,11 @@ static const struct Command winecmd_commands[] = {
{ .name = "download", .func = winecmd_download, .description = "download and extract a wine version" },
{ .name = "env", .func = winecmd_env, .description = "add wine to your PATH in a POSIX shell"},
{ .name = "env-fish", .func = winecmd_env, .description = "add wine to your PATH in the fish shell"},
- { .name = "list", .func = winecmd_list, .description = "list available wine versions" },
{ .name = "installed", .func = winecmd_installed, .description = "list installed wine versions" },
+ { .name = "list", .func = winecmd_list, .description = "list available wine versions" },
{ .name = "remove", .func = winecmd_remove, .description = "remove a wine version" },
{ .name = "run", .func = winecmd_run, .description = "run an installed wine version" },
+ { .name = "shim", .func = winecmd_shim, .description = "add a wine shim to your users bin folder" },
};
static const struct Flag winecmd_flags[] = {
@@ -248,8 +249,11 @@ COMMAND(winecmd, run)
}
}
+ else
+ {
+ fprintf(stderr, USAGE_STR " wine run [version] <options>\nUse '" NAME " wine list-installed' to list available versions\n");
+ }
- fprintf(stderr, "Specify a what wine version to run.\nUse '" NAME " wine list-installed' to list available versions\n");
return EXIT_SUCCESS;
}
@@ -376,7 +380,80 @@ COMMAND(winecmd, env)
}
else
{
- fprintf(stderr, "Specify a what wine version to run.\nUse '" NAME " wine list-installed' to list available versions\n");
+ fprintf(stderr, USAGE_STR " wine env [version] <options>\nUse '" NAME " wine list-installed' to list available versions\n");
+ }
+
+ return EXIT_SUCCESS;
+}
+
+COMMAND(winecmd, shim)
+{
+ if (argc > 1)
+ {
+ char winepath[PATH_MAX];
+ char* winebinloc = NULL; // to be set by the wine type check
+ getWineDir(winepath, sizeof(winepath));
+ char* winever = argv[1];
+
+ strncat(winepath, "/", sizeof(winepath) - strlen(winepath) - 1);
+ strncat(winepath, winever, sizeof(winepath) - strlen(winepath) - 1);
+
+ if (!isDir(winepath))
+ {
+
+ // try appending the system arch to find the wine version
+ struct utsname buffer;
+
+ if (!uname(&buffer))
+ {
+ strncat(winepath, "-", sizeof(winepath) - strlen(winepath) - 1);
+ strncat(winepath, buffer.machine, sizeof(winepath) - strlen(winepath) - 1);
+ }
+
+ // if we still cannot find anything tell the user and exit
+ if (!isDir(winepath))
+ {
+ fprintf(stderr, "'%s' is not an installed wine version\n", winever);
+ return 1;
+ }
+ }
+
+ switch(check_wine_ver(winepath, sizeof(winepath)+1))
+ {
+ default:
+ case WINE_NORMAL:
+ winebinloc = WINEBIN;
+ break;
+
+ case WINE_PROTON:
+ winebinloc = PROTONBIN;
+ break;
+ }
+
+ strncat(winepath, winebinloc, sizeof(winepath) - strlen(winepath) - 1);
+
+ if (isFile(winepath))
+ {
+ char buffer[BUFSIZ];
+ char binpath[PATH_MAX];
+
+ readlink("/proc/self/exe", buffer, BUFSIZ);
+ getUserBinDir(binpath, sizeof(binpath));
+ strcat(binpath, "/wine-");
+ strcat(binpath, winever);
+
+ symlink(buffer, binpath);
+ printf("Installed '%s' as '%s'ยด\n", winever, binpath);
+ }
+ else
+ {
+ fprintf(stderr, "cannot find wine for '%s'\n", winever);
+ }
+
+ }
+ else
+ {
+ fprintf(stderr, USAGE_STR " wine shim [version]\n");
}
return EXIT_SUCCESS;