Merge pull request #1631 from laciba96/master

Add support for overridable VM name
This commit is contained in:
Miran Grča
2021-09-01 15:02:10 +02:00
committed by GitHub
3 changed files with 25 additions and 5 deletions

View File

@@ -110,6 +110,7 @@ uint64_t unique_id = 0;
uint64_t source_hwnd = 0;
#endif
char log_path[1024] = { '\0'}; /* (O) full path of logfile */
char vm_name[1024] = { '\0'}; /* (O) display name of the VM */
/* Configuration values. */
int window_w; /* (C) window size and */
@@ -417,6 +418,7 @@ usage:
printf("-F or --fullscreen - start in fullscreen mode\n");
printf("-L or --logfile path - set 'path' to be the logfile\n");
printf("-P or --vmpath path - set 'path' to be root for vm\n");
printf("-V or --vmname name - overrides the name of the running VM.\n");
printf("-S or --settings - show only the settings dialog\n");
printf("-N or --noconfirm - do not ask for confirmation on quit\n");
#ifdef _WIN32
@@ -446,6 +448,11 @@ usage:
if ((c+1) == argc) goto usage;
strcpy(path, argv[++c]);
} else if (!strcasecmp(argv[c], "--vmname") ||
!strcasecmp(argv[c], "-V")) {
if ((c+1) == argc) goto usage;
strcpy(vm_name, argv[++c]);
} else if (!strcasecmp(argv[c], "--settings") ||
!strcasecmp(argv[c], "-S")) {
settings_only = 1;
@@ -551,6 +558,20 @@ usage:
/* At this point, we can safely create the full path name. */
plat_append_filename(cfg_path, usr_path, p);
/*
* Get the current directory's name
*
* At this point usr_path is perfectly initialized.
* If no --vmname parameter specified we'll use the
* working directory name as the VM's name.
*/
if (strlen(vm_name) == 0)
{
char ltemp[1024] = { '\0'};
plat_get_dirname(ltemp, usr_path);
strcpy(vm_name, plat_get_filename(ltemp));
}
/*
* This is where we start outputting to the log file,
* if there is one. Create a little info header first.

View File

@@ -80,6 +80,7 @@ extern uint64_t unique_id;
extern uint64_t source_hwnd;
#endif
extern char log_path[1024]; /* (O) full path of logfile */
extern char vm_name[1024]; /* (O) display name of the VM */
extern int window_w, window_h, /* (C) window size and */

View File

@@ -68,7 +68,7 @@ void
discord_update_activity(int paused)
{
struct DiscordActivity activity;
char config_name[1024], cpufamily[1024];
char cpufamily[1024];
char *paren;
if(discord_activities == NULL)
@@ -78,16 +78,14 @@ discord_update_activity(int paused)
memset(&activity, 0x00, sizeof(activity));
plat_get_dirname(config_name, usr_path);
strncpy(cpufamily, cpu_f->name, sizeof(cpufamily) - 1);
paren = strchr(cpufamily, '(');
if (paren)
*(paren - 1) = '\0';
if (strlen(plat_get_filename(config_name)) < 100)
if (strlen(vm_name) < 100)
{
sprintf_s(activity.details, sizeof(activity.details), "Running \"%s\"", plat_get_filename(config_name));
sprintf_s(activity.details, sizeof(activity.details), "Running \"%s\"", vm_name);
sprintf_s(activity.state, sizeof(activity.state), "%s (%s/%s)", strchr(machine_getname(), ']') + 2, cpufamily, cpu_s->name);
}
else