summaryrefslogtreecommitdiffstats
path: root/source/dialogs
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2017-02-17 14:06:31 +0100
committerDave Davenport <qball@gmpclient.org>2017-02-17 14:06:31 +0100
commitdc7e4aa96e5fd6b3efd073d6b1d86606b0545bca (patch)
tree1d7a83f5c1e9e8ace83790c7b428f05161f0ed66 /source/dialogs
parentf7b4bebb9b6188c5eee3d7e76c89f5b6d574f98d (diff)
Install some headers for use in plugins
Diffstat (limited to 'source/dialogs')
-rw-r--r--source/dialogs/drun.c34
-rw-r--r--source/dialogs/run.c36
-rw-r--r--source/dialogs/ssh.c1
3 files changed, 4 insertions, 67 deletions
diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c
index 4415c3d3..03c842c2 100644
--- a/source/dialogs/drun.c
+++ b/source/dialogs/drun.c
@@ -50,36 +50,6 @@
#define DRUN_CACHE_FILE "rofi2.druncache"
#define LOG_DOMAIN "Dialogs.DRun"
-static inline int execsh ( const char *wd, const char *cmd, int run_in_term )
-{
- int retv = TRUE;
- char **args = NULL;
- int argc = 0;
- if ( !cmd || !cmd[0] ) {
- return 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 );
- if ( error != NULL ) {
- char *msg = g_strdup_printf ( "Failed to execute: '%s'\nError: '%s'", cmd, error->message );
- rofi_view_error_dialog ( msg, FALSE );
- g_free ( msg );
- // print error.
- g_error_free ( error );
- retv = FALSE;
- }
-
- // Free the args list.
- g_strfreev ( args );
- return retv;
-}
-
/**
* Store extra information about the entry.
* Currently the executable and if it should run in terminal.
@@ -201,7 +171,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 ( execsh ( exec_path, fp, terminal ) ) {
+ if ( helper_execute_command ( exec_path, fp, terminal ) ) {
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 );
@@ -462,7 +432,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' ) {
- execsh ( NULL, *input, run_in_term );
+ helper_execute_command ( NULL, *input, run_in_term );
}
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 bf55b77b..e9ba44c6 100644
--- a/source/dialogs/run.c
+++ b/source/dialogs/run.c
@@ -70,40 +70,6 @@ typedef struct
unsigned int cmd_list_length;
} RunModePrivateData;
-/**
- * @param cmd The cmd to execute
- * @param run_in_term Indicate if command should be run in a terminal
- *
- * Execute command.
- *
- * @returns FALSE On failure, TRUE on success
- */
-static inline int execsh ( const char *cmd, int run_in_term )
-{
- 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 ( NULL, args, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &error );
- if ( error != NULL ) {
- char *msg = g_strdup_printf ( "Failed to execute: '%s'\nError: '%s'", cmd, error->message );
- rofi_view_error_dialog ( msg, FALSE );
- g_free ( msg );
- // print error.
- g_error_free ( error );
- retv = FALSE;
- }
-
- // Free the args list.
- g_strfreev ( args );
- return retv;
-}
/**
* @param cmd The cmd to execute
@@ -126,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 ( execsh ( lf_cmd, run_in_term ) ) {
+ if ( helper_execute_command ( NULL, lf_cmd, run_in_term ) ) {
/**
* 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 9a0909a0..d2ffbed9 100644
--- a/source/dialogs/ssh.c
+++ b/source/dialogs/ssh.c
@@ -30,6 +30,7 @@
* @{
*/
#include <config.h>
+#include <glib.h>
#include <stdlib.h>
#include <stdio.h>