run-{shell-,}command: expand `{app_id}` inside the template string
This commit is contained in:
parent
c1e71bb2bc
commit
8e01fcd16f
|
@ -319,7 +319,9 @@ gboolean helper_execute(const char *wd, char **args, const char *error_precmd,
|
|||
* @param wd The work directory (optional)
|
||||
* @param cmd The cmd to execute
|
||||
* @param run_in_term Indicate if command should be run in a terminal
|
||||
* @param context The startup notification context, if any
|
||||
* @param startup_notify True if the command is expected to notify on startup
|
||||
* @param context Additional information about the application, such as its
|
||||
* app_id. May be NULL.
|
||||
*
|
||||
* Execute command.
|
||||
* If needed members of context are NULL, they will be filled.
|
||||
|
@ -328,6 +330,7 @@ gboolean helper_execute(const char *wd, char **args, const char *error_precmd,
|
|||
*/
|
||||
gboolean helper_execute_command(const char *wd, const char *cmd,
|
||||
gboolean run_in_term,
|
||||
gboolean startup_notify,
|
||||
RofiHelperExecuteContext *context);
|
||||
|
||||
/**
|
||||
|
|
|
@ -1027,15 +1027,20 @@ gboolean helper_execute(const char *wd, char **args, const char *error_precmd,
|
|||
|
||||
gboolean helper_execute_command(const char *wd, const char *cmd,
|
||||
gboolean run_in_term,
|
||||
gboolean startup_notify,
|
||||
RofiHelperExecuteContext *context) {
|
||||
char **args = NULL;
|
||||
int argc = 0;
|
||||
|
||||
if (run_in_term) {
|
||||
helper_parse_setup(config.run_shell_command, &args, &argc, "{cmd}", cmd,
|
||||
helper_parse_setup(config.run_shell_command, &args, &argc,
|
||||
"{cmd}", cmd,
|
||||
"{app_id}", context ? context->app_id : "",
|
||||
(char *)0);
|
||||
} else {
|
||||
helper_parse_setup(config.run_command, &args, &argc, "{cmd}", cmd,
|
||||
helper_parse_setup(config.run_command, &args, &argc,
|
||||
"{cmd}", cmd,
|
||||
"{app_id}", context ? context->app_id : "",
|
||||
(char *)0);
|
||||
}
|
||||
|
||||
|
@ -1062,7 +1067,7 @@ gboolean helper_execute_command(const char *wd, const char *cmd,
|
|||
}
|
||||
}
|
||||
|
||||
return helper_execute(wd, args, "", cmd, context);
|
||||
return helper_execute(wd, args, "", cmd, startup_notify ? context : NULL);
|
||||
}
|
||||
|
||||
char *helper_get_theme_path(const char *file, const char **ext,
|
||||
|
|
|
@ -323,7 +323,7 @@ static void launch_link_entry(DRunModeEntry *e) {
|
|||
g_free(url);
|
||||
|
||||
g_debug("Link launch command: |%s|", command);
|
||||
if (helper_execute_command(NULL, command, FALSE, NULL)) {
|
||||
if (helper_execute_command(NULL, command, FALSE, FALSE, NULL)) {
|
||||
char *path = g_build_filename(cache_dir, DRUN_CACHE_FILE, NULL);
|
||||
// Store it based on the unique identifiers (desktop_id).
|
||||
history_set(path, e->desktop_id);
|
||||
|
@ -403,7 +403,7 @@ static void exec_cmd_entry(DRunModeEntry *e, const char *path) {
|
|||
// terminal.
|
||||
gboolean terminal =
|
||||
g_key_file_get_boolean(e->key_file, e->action, "Terminal", NULL);
|
||||
if (helper_execute_command(exec_path, fp, terminal, sn ? &context : NULL)) {
|
||||
if (helper_execute_command(exec_path, fp, terminal, sn, &context)) {
|
||||
char *drun_cach_path = g_build_filename(cache_dir, DRUN_CACHE_FILE, NULL);
|
||||
// Store it based on the unique identifiers (desktop_id).
|
||||
history_set(drun_cach_path, e->desktop_id);
|
||||
|
@ -1229,7 +1229,7 @@ static ModeMode drun_mode_result(Mode *sw, int mretv, char **input,
|
|||
gboolean run_in_term = ((mretv & MENU_CUSTOM_ACTION) == MENU_CUSTOM_ACTION);
|
||||
// FIXME: We assume startup notification in terminals, not in others
|
||||
if (!helper_execute_command(NULL, *input, run_in_term,
|
||||
run_in_term ? &context : NULL)) {
|
||||
run_in_term, &context)) {
|
||||
retv = RELOAD_DIALOG;
|
||||
}
|
||||
} else if ((mretv & MENU_ENTRY_DELETE) &&
|
||||
|
|
|
@ -504,7 +504,7 @@ static ModeMode file_browser_mode_result(Mode *sw, int mretv, char **input,
|
|||
char *cmd = g_strdup_printf("%s %s", pd->command, d_esc);
|
||||
g_free(d_esc);
|
||||
char *cdir = g_file_get_path(pd->current_dir);
|
||||
helper_execute_command(cdir, cmd, FALSE, NULL);
|
||||
helper_execute_command(cdir, cmd, FALSE, FALSE, NULL);
|
||||
g_free(cdir);
|
||||
g_free(cmd);
|
||||
return MODE_EXIT;
|
||||
|
|
|
@ -370,7 +370,7 @@ static ModeMode recursive_browser_mode_result(Mode *sw, int mretv, G_GNUC_UNUSED
|
|||
char *cmd = g_strdup_printf("%s %s", pd->command, d_esc);
|
||||
g_free(d_esc);
|
||||
char *cdir = g_file_get_path(pd->current_dir);
|
||||
helper_execute_command(cdir, cmd, FALSE, NULL);
|
||||
helper_execute_command(cdir, cmd, FALSE, FALSE, NULL);
|
||||
g_free(cdir);
|
||||
g_free(cmd);
|
||||
return MODE_EXIT;
|
||||
|
|
|
@ -117,7 +117,7 @@ static gboolean exec_cmd(const char *cmd, int run_in_term, const char *orig) {
|
|||
RofiHelperExecuteContext context = {.name = NULL};
|
||||
// FIXME: assume startup notification support for terminals
|
||||
if (helper_execute_command(NULL, lf_cmd, run_in_term,
|
||||
run_in_term ? &context : NULL)) {
|
||||
run_in_term, &context)) {
|
||||
/**
|
||||
* This happens in non-critical time (After launching app)
|
||||
* It is allowed to be a bit slower.
|
||||
|
|
|
@ -846,7 +846,7 @@ static ModeMode window_mode_result(Mode *sw, int mretv,
|
|||
|
||||
RofiHelperExecuteContext context = {.name = NULL};
|
||||
if (!helper_execute_command(NULL, lf_cmd, run_in_term,
|
||||
run_in_term ? &context : NULL)) {
|
||||
run_in_term, &context)) {
|
||||
retv = RELOAD_DIALOG;
|
||||
}
|
||||
g_free(lf_cmd);
|
||||
|
|
Loading…
Reference in New Issue