diff options
author | Dave Davenport <qball@gmpclient.org> | 2017-06-02 18:52:28 +0200 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2017-06-02 18:52:28 +0200 |
commit | 4cd2d87ed2c0a5ea6741c866896a6f007e0b260a (patch) | |
tree | e1049b1eb78b9f0bb2848ac68e0b38a3e585858f /source/helper.c | |
parent | 1be94387110d35a0df4f909a3d672fae573c24b9 (diff) | |
parent | 76a6e312fe1d86c7a29e3839d1c0311e9c583c18 (diff) |
Merge remote-tracking branch 'origin/master' into barview
Diffstat (limited to 'source/helper.c')
-rw-r--r-- | source/helper.c | 59 |
1 files changed, 46 insertions, 13 deletions
diff --git a/source/helper.c b/source/helper.c index b1220fbd..33180096 100644 --- a/source/helper.c +++ b/source/helper.c @@ -47,6 +47,7 @@ #include <pango/pango-fontmap.h> #include <pango/pangocairo.h> #include <librsvg/rsvg.h> +#include "display.h" #include "xcb.h" #include "helper.h" #include "helper-theme.h" @@ -962,21 +963,19 @@ int utf8_strncmp ( const char* a, const char* b, size_t n ) return r; } -int helper_execute_command ( const char *wd, const char *cmd, int run_in_term ) +gboolean helper_execute ( const char *wd, char **args, const char *error_precmd, const char *error_cmd, RofiHelperExecuteContext *context ) { - int retv = TRUE; - char **args = NULL; - int argc = 0; - if ( run_in_term ) { - helper_parse_setup ( config.run_shell_command, &args, &argc, "{cmd}", cmd, NULL ); - } - else { - helper_parse_setup ( config.run_command, &args, &argc, "{cmd}", cmd, NULL ); - } - GError *error = NULL; - g_spawn_async ( wd, args, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &error ); + gboolean retv = TRUE; + GError *error = NULL; + + GSpawnChildSetupFunc child_setup = NULL; + gpointer user_data = NULL; + + display_startup_notification ( context, &child_setup, &user_data ); + + g_spawn_async ( wd, args, NULL, G_SPAWN_SEARCH_PATH, child_setup, user_data, NULL, &error ); if ( error != NULL ) { - char *msg = g_strdup_printf ( "Failed to execute: '%s'\nError: '%s'", cmd, error->message ); + char *msg = g_strdup_printf ( "Failed to execute: '%s%s'\nError: '%s'", error_precmd, error_cmd, error->message ); rofi_view_error_dialog ( msg, FALSE ); g_free ( msg ); // print error. @@ -989,6 +988,40 @@ int helper_execute_command ( const char *wd, const char *cmd, int run_in_term ) return retv; } +gboolean helper_execute_command ( const char *wd, const char *cmd, gboolean run_in_term, RofiHelperExecuteContext *context ) +{ + char **args = NULL; + int argc = 0; + + if ( run_in_term ) { + helper_parse_setup ( config.run_shell_command, &args, &argc, "{cmd}", cmd, NULL ); + } + else { + helper_parse_setup ( config.run_command, &args, &argc, "{cmd}", cmd, NULL ); + } + + if ( context != NULL ) { + if ( context->name == NULL ) { + context->name = args[0]; + } + if ( context->binary == NULL ) { + context->binary = args[0]; + } + if ( context->description == NULL ) { + gsize l = strlen ( "Launching '' via rofi" ) + strlen ( cmd ) + 1; + gchar *description = g_newa ( gchar, l ); + + g_snprintf ( description, l, "Launching '%s' via rofi", cmd ); + context->description = description; + } + if ( context->command == NULL ) { + context->command = cmd; + } + } + + return helper_execute ( wd, args, "", cmd, context ); +} + char *helper_get_theme_path ( const char *file ) { char *filename = rofi_expand_path ( file ); |