summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorQuentin Glidic <sardemff7+git@sardemff7.net>2017-06-02 14:54:21 +0200
committerQuentin Glidic <sardemff7+git@sardemff7.net>2017-06-02 14:54:21 +0200
commit51d34b662e95399ca23caededa9f61f7a7e1dca3 (patch)
treea5ca20235b4f0feb93ef071df2db8018d46b8f83 /source
parent6fefbbf8ab47b87fc4cb4a70f82c7bcc0b91587b (diff)
helper: Add API to support startup notification
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Diffstat (limited to 'source')
-rw-r--r--source/dialogs/drun.c4
-rw-r--r--source/dialogs/run.c2
-rw-r--r--source/dialogs/ssh.c2
-rw-r--r--source/helper.c28
-rw-r--r--source/xcb.c4
5 files changed, 33 insertions, 7 deletions
diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c
index b4834c4f..f9686b99 100644
--- a/source/dialogs/drun.c
+++ b/source/dialogs/drun.c
@@ -185,7 +185,7 @@ static void exec_cmd_entry ( DRunModeEntry *e )
// Returns false if not found, if key not found, we don't want run in terminal.
gboolean terminal = g_key_file_get_boolean ( e->key_file, "Desktop Entry", "Terminal", NULL );
- if ( helper_execute_command ( exec_path, fp, terminal ) ) {
+ if ( helper_execute_command ( exec_path, fp, terminal, NULL ) ) {
char *path = g_build_filename ( cache_dir, DRUN_CACHE_FILE, NULL );
char *key = g_strdup_printf ( "%s:::%s", e->root, e->path );
history_set ( path, key );
@@ -511,7 +511,7 @@ static ModeMode drun_mode_result ( Mode *sw, int mretv, char **input, unsigned i
exec_cmd_entry ( &( rmpd->entry_list[selected_line] ) );
}
else if ( ( mretv & MENU_CUSTOM_INPUT ) && *input != NULL && *input[0] != '\0' ) {
- helper_execute_command ( NULL, *input, run_in_term );
+ helper_execute_command ( NULL, *input, run_in_term, NULL );
}
else if ( ( mretv & MENU_ENTRY_DELETE ) && selected_line < rmpd->cmd_list_length ) {
if ( selected_line < rmpd->history_length ) {
diff --git a/source/dialogs/run.c b/source/dialogs/run.c
index 9a19d662..0acde0a2 100644
--- a/source/dialogs/run.c
+++ b/source/dialogs/run.c
@@ -92,7 +92,7 @@ static void exec_cmd ( const char *cmd, int run_in_term )
}
char *path = g_build_filename ( cache_dir, RUN_CACHE_FILE, NULL );
- if ( helper_execute_command ( NULL, lf_cmd, run_in_term ) ) {
+ if ( helper_execute_command ( NULL, lf_cmd, run_in_term, NULL ) ) {
/**
* This happens in non-critical time (After launching app)
* It is allowed to be a bit slower.
diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c
index 66fdc74a..5be70221 100644
--- a/source/dialogs/ssh.c
+++ b/source/dialogs/ssh.c
@@ -81,7 +81,7 @@ static inline int execshssh ( const char *host )
helper_parse_setup ( config.ssh_command, &args, &argsv, "{host}", host, NULL );
- return helper_execute ( NULL, args, "ssh ", host );
+ return helper_execute ( NULL, args, "ssh ", host, NULL );
}
/**
diff --git a/source/helper.c b/source/helper.c
index ebcf783d..2eac638e 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,7 +963,7 @@ int utf8_strncmp ( const char* a, const char* b, size_t n )
return r;
}
-gboolean helper_execute ( const char *wd, char **args, const char *error_precmd, const char *error_cmd )
+gboolean helper_execute ( const char *wd, char **args, const char *error_precmd, const char *error_cmd, RofiHelperExecuteContext *context )
{
gboolean retv = TRUE;
GError *error = NULL;
@@ -970,6 +971,8 @@ gboolean helper_execute ( const char *wd, char **args, const char *error_precmd,
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%s'\nError: '%s'", error_precmd, error_cmd, error->message );
@@ -985,7 +988,7 @@ gboolean helper_execute ( const char *wd, char **args, const char *error_precmd,
return retv;
}
-gboolean helper_execute_command ( const char *wd, const char *cmd, int run_in_term )
+gboolean helper_execute_command ( const char *wd, const char *cmd, gboolean run_in_term, RofiHelperExecuteContext *context )
{
char **args = NULL;
int argc = 0;
@@ -997,7 +1000,26 @@ gboolean helper_execute_command ( const char *wd, const char *cmd, int run_in_te
helper_parse_setup ( config.run_command, &args, &argc, "{cmd}", cmd, NULL );
}
- return helper_execute ( wd, args, "", cmd );
+ 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 )
diff --git a/source/xcb.c b/source/xcb.c
index 13dbdd6a..57130c5d 100644
--- a/source/xcb.c
+++ b/source/xcb.c
@@ -359,6 +359,10 @@ void display_dump_monitor_layout ( void )
}
}
+void display_startup_notification ( RofiHelperExecuteContext *context, GSpawnChildSetupFunc *child_setup, gpointer *user_data )
+{
+}
+
static int monitor_get_dimension ( int monitor_id, workarea *mon )
{
memset ( mon, 0, sizeof ( workarea ) );