mirror of
https://github.com/FreeRDP/FreeRDP.git
synced 2025-06-03 00:00:20 +00:00
Add command line option to override action script path
This commit is contained in:
parent
6af6aba144
commit
e7487cea27
@ -97,7 +97,7 @@ BOOL xf_event_action_script_init(xfContext* xfc)
|
||||
return FALSE;
|
||||
|
||||
ArrayList_Object(xfc->xevents)->fnObjectFree = free;
|
||||
sprintf_s(command, sizeof(command), "%s xevent", xfc->actionScript);
|
||||
sprintf_s(command, sizeof(command), "%s xevent", xfc->context.settings->ActionScript);
|
||||
actionScript = popen(command, "r");
|
||||
|
||||
if (!actionScript)
|
||||
@ -140,7 +140,7 @@ static BOOL xf_event_execute_action_script(xfContext* xfc, XEvent* event)
|
||||
char buffer[1024] = { 0 };
|
||||
char command[1024] = { 0 };
|
||||
|
||||
if (!xfc->actionScript || !xfc->xevents)
|
||||
if (!xfc->actionScriptExists || !xfc->xevents)
|
||||
return FALSE;
|
||||
|
||||
if (event->type > (sizeof(X11_EVENT_STRINGS) / sizeof(const char*)))
|
||||
@ -164,7 +164,7 @@ static BOOL xf_event_execute_action_script(xfContext* xfc, XEvent* event)
|
||||
return FALSE;
|
||||
|
||||
sprintf_s(command, sizeof(command), "%s xevent %s %lu",
|
||||
xfc->actionScript, xeventName, (unsigned long) xfc->window->handle);
|
||||
xfc->context.settings->ActionScript, xeventName, (unsigned long) xfc->window->handle);
|
||||
actionScript = popen(command, "r");
|
||||
|
||||
if (!actionScript)
|
||||
|
@ -53,16 +53,9 @@ BOOL xf_keyboard_action_script_init(xfContext* xfc)
|
||||
char buffer[1024] = { 0 };
|
||||
char command[1024] = { 0 };
|
||||
|
||||
if (xfc->actionScript)
|
||||
{
|
||||
free(xfc->actionScript);
|
||||
xfc->actionScript = NULL;
|
||||
}
|
||||
xfc->actionScriptExists = PathFileExistsA(xfc->context.settings->ActionScript);
|
||||
|
||||
if (PathFileExistsA("/usr/share/freerdp/action.sh"))
|
||||
xfc->actionScript = _strdup("/usr/share/freerdp/action.sh");
|
||||
|
||||
if (!xfc->actionScript)
|
||||
if (!xfc->actionScriptExists)
|
||||
return FALSE;
|
||||
|
||||
xfc->keyCombinations = ArrayList_New(TRUE);
|
||||
@ -71,13 +64,12 @@ BOOL xf_keyboard_action_script_init(xfContext* xfc)
|
||||
return FALSE;
|
||||
|
||||
ArrayList_Object(xfc->keyCombinations)->fnObjectFree = free;
|
||||
sprintf_s(command, sizeof(command), "%s key", xfc->actionScript);
|
||||
sprintf_s(command, sizeof(command), "%s key", xfc->context.settings->ActionScript);
|
||||
keyScript = popen(command, "r");
|
||||
|
||||
if (!keyScript)
|
||||
{
|
||||
free(xfc->actionScript);
|
||||
xfc->actionScript = NULL;
|
||||
xfc->actionScriptExists = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -89,8 +81,7 @@ BOOL xf_keyboard_action_script_init(xfContext* xfc)
|
||||
if (!keyCombination || ArrayList_Add(xfc->keyCombinations, keyCombination) < 0)
|
||||
{
|
||||
ArrayList_Free(xfc->keyCombinations);
|
||||
free(xfc->actionScript);
|
||||
xfc->actionScript = NULL;
|
||||
xfc->actionScriptExists = FALSE;
|
||||
pclose(keyScript);
|
||||
return FALSE;
|
||||
}
|
||||
@ -108,12 +99,7 @@ void xf_keyboard_action_script_free(xfContext* xfc)
|
||||
{
|
||||
ArrayList_Free(xfc->keyCombinations);
|
||||
xfc->keyCombinations = NULL;
|
||||
}
|
||||
|
||||
if (xfc->actionScript)
|
||||
{
|
||||
free(xfc->actionScript);
|
||||
xfc->actionScript = NULL;
|
||||
xfc->actionScriptExists = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -380,7 +366,7 @@ static int xf_keyboard_execute_action_script(xfContext* xfc,
|
||||
char command[1024] = { 0 };
|
||||
char combination[1024] = { 0 };
|
||||
|
||||
if (!xfc->actionScript)
|
||||
if (!xfc->actionScriptExists)
|
||||
return 1;
|
||||
|
||||
if ((keysym == XK_Shift_L) || (keysym == XK_Shift_R) ||
|
||||
@ -424,7 +410,7 @@ static int xf_keyboard_execute_action_script(xfContext* xfc,
|
||||
return 1;
|
||||
|
||||
sprintf_s(command, sizeof(command), "%s key %s",
|
||||
xfc->actionScript, combination);
|
||||
xfc->context.settings->ActionScript, combination);
|
||||
keyScript = popen(command, "r");
|
||||
|
||||
if (!keyScript)
|
||||
|
@ -25,8 +25,6 @@
|
||||
#include "xf_client.h"
|
||||
#include "xfreerdp.h"
|
||||
|
||||
#define XF_ACTION_SCRIPT "~/.config/freerdp/action.sh"
|
||||
|
||||
struct _XF_MODIFIER_KEYS
|
||||
{
|
||||
BOOL Shift;
|
||||
|
@ -171,7 +171,7 @@ struct xf_context
|
||||
XModifierKeymap* modifierMap;
|
||||
wArrayList* keyCombinations;
|
||||
wArrayList* xevents;
|
||||
char* actionScript;
|
||||
BOOL actionScriptExists;
|
||||
|
||||
XSetWindowAttributes attribs;
|
||||
BOOL complex_regions;
|
||||
|
@ -187,6 +187,7 @@ static COMMAND_LINE_ARGUMENT_A args[] =
|
||||
{ "scale", COMMAND_LINE_VALUE_REQUIRED, "<scale amount (%%)>", "100", NULL, -1, NULL, "Scaling factor of the display (value of 100, 140, or 180)" },
|
||||
{ "scale-desktop", COMMAND_LINE_VALUE_REQUIRED, "<scale amount (%%)>", "100", NULL, -1, NULL, "Scaling factor for desktop applications (value between 100 and 500)" },
|
||||
{ "scale-device", COMMAND_LINE_VALUE_REQUIRED, "<scale amount (%%)>", "100", NULL, -1, NULL, "Scaling factor for app store applications (100, 140, or 180)" },
|
||||
{ "action-script", COMMAND_LINE_VALUE_REQUIRED, "<file name>", "/usr/share/freerdp/action.sh", NULL, -1, NULL, "Action script" },
|
||||
{ NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
|
||||
};
|
||||
|
||||
@ -2506,6 +2507,12 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
return COMMAND_LINE_ERROR;
|
||||
}
|
||||
}
|
||||
CommandLineSwitchCase(arg, "action-script")
|
||||
{
|
||||
free (settings->ActionScript);
|
||||
if (!(settings->ActionScript = _strdup(arg->Value)))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchDefault(arg)
|
||||
{
|
||||
}
|
||||
|
@ -1434,6 +1434,7 @@ struct rdp_settings
|
||||
|
||||
ALIGN64 BYTE*
|
||||
SettingsModified; /* byte array marking fields that have been modified from their default value */
|
||||
ALIGN64 char* ActionScript;
|
||||
};
|
||||
typedef struct rdp_settings rdpSettings;
|
||||
|
||||
|
@ -680,6 +680,7 @@ rdpSettings* freerdp_settings_clone(rdpSettings* settings)
|
||||
CHECKED_STRDUP(RemoteApplicationCmdLine); /* 2118 */
|
||||
CHECKED_STRDUP(ImeFileName); /* 2628 */
|
||||
CHECKED_STRDUP(DrivesToRedirect); /* 4290 */
|
||||
CHECKED_STRDUP(ActionScript);
|
||||
/**
|
||||
* Manual Code
|
||||
*/
|
||||
@ -1080,6 +1081,7 @@ void freerdp_settings_free(rdpSettings* settings)
|
||||
free(settings->DrivesToRedirect);
|
||||
free(settings->WindowTitle);
|
||||
free(settings->WmClass);
|
||||
free(settings->ActionScript);
|
||||
freerdp_target_net_addresses_free(settings);
|
||||
freerdp_device_collection_free(settings);
|
||||
freerdp_static_channel_collection_free(settings);
|
||||
|
Loading…
Reference in New Issue
Block a user