run-{shell-,}command: expand {app_id}
inside the template string
This commit is contained in:
@@ -322,7 +322,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.
|
||||
@@ -331,6 +333,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);
|
||||
|
||||
/**
|
||||
|
@@ -1071,15 +1071,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);
|
||||
}
|
||||
|
||||
@@ -1106,7 +1111,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);
|
||||
}
|
||||
|
||||
static char *helper_get_theme_path_check_file(const char *filename,
|
||||
|
@@ -330,7 +330,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);
|
||||
@@ -509,7 +509,7 @@ static void exec_cmd_entry(DRunModePrivateData *pd, DRunModeEntry *e,
|
||||
// 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);
|
||||
@@ -1421,7 +1421,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) &&
|
||||
|
@@ -498,7 +498,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;
|
||||
|
@@ -420,7 +420,7 @@ static ModeMode recursive_browser_mode_result(Mode *sw, int mretv,
|
||||
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;
|
||||
|
@@ -120,7 +120,7 @@ static gboolean exec_cmd(const char *cmd, int run_in_term, const char *orig) {
|
||||
char *hist = g_strdup_printf("%s\x1f%s", orig, cmd);
|
||||
// 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.
|
||||
|
@@ -852,7 +852,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);
|
||||
|
@@ -1482,13 +1482,13 @@ static void rofi_quit_user_callback(RofiViewState *state) {
|
||||
} else if (state->retv & MENU_CANCEL) {
|
||||
if (config.on_menu_canceled == NULL)
|
||||
return;
|
||||
helper_execute_command(NULL, config.on_menu_canceled, FALSE, NULL);
|
||||
helper_execute_command(NULL, config.on_menu_canceled, FALSE, FALSE, NULL);
|
||||
} else if (state->retv & MENU_NEXT || state->retv & MENU_PREVIOUS ||
|
||||
state->retv & MENU_QUICK_SWITCH || state->retv & MENU_COMPLETE) {
|
||||
if (config.on_mode_changed == NULL)
|
||||
return;
|
||||
// TODO: pass mode name to custom command
|
||||
helper_execute_command(NULL, config.on_mode_changed, FALSE, NULL);
|
||||
helper_execute_command(NULL, config.on_mode_changed, FALSE, FALSE, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user