1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Fix issue #482: Set work directory

This commit is contained in:
Dave Davenport 2016-10-15 20:00:26 +02:00
parent e95b2047bd
commit cdb1b96414
5 changed files with 34 additions and 36 deletions

View file

@ -49,11 +49,14 @@
#define DRUN_CACHE_FILE "rofi2.druncache"
#define LOG_DOMAIN "Dialogs.DRun"
static inline int execsh ( const char *cmd, int run_in_term )
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 );
}
@ -61,7 +64,7 @@ static inline int execsh ( const char *cmd, int run_in_term )
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 );
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 );
@ -76,16 +79,6 @@ static inline int execsh ( const char *cmd, int run_in_term )
return retv;
}
// execute sub-process
static void exec_cmd ( const char *cmd, int run_in_term )
{
if ( !cmd || !cmd[0] ) {
return;
}
execsh ( cmd, run_in_term );
}
/**
* Store extra information about the entry.
* Currently the executable and if it should run in terminal.
@ -100,6 +93,8 @@ typedef struct
char *path;
/* Executable */
char *exec;
/* Path */
char *exec_path;
/* Name of the Entry */
char *name;
/* Generic Name */
@ -199,7 +194,7 @@ static void exec_cmd_entry ( DRunModeEntry *e )
return;
}
gchar *fp = rofi_expand_path ( g_strstrip ( str ) );
if ( execsh ( fp, e->terminal ) ) {
if ( execsh ( e->exec_path, fp, e->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 );
@ -313,6 +308,11 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const
if ( g_key_file_has_key ( kf, "Desktop Entry", "Terminal", NULL ) ) {
pd->entry_list[pd->cmd_list_length].terminal = g_key_file_get_boolean ( kf, "Desktop Entry", "Terminal", NULL );
}
pd->entry_list[pd->cmd_list_length].exec_path = NULL;
if ( g_key_file_has_key ( kf, "Desktop Entry", "Path", NULL ) ) {
pd->entry_list[pd->cmd_list_length].exec_path = g_key_file_get_string ( kf, "Desktop Entry", "Path", NULL );
}
( pd->cmd_list_length )++;
}
@ -447,6 +447,7 @@ static void drun_entry_clear ( DRunModeEntry *e )
g_free ( e->root );
g_free ( e->path );
g_free ( e->exec );
g_free ( e->exec_path );
g_free ( e->name );
g_free ( e->generic_name );
}
@ -471,7 +472,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' ) {
exec_cmd ( *input, run_in_term );
execsh ( NULL, *input, run_in_term );
}
else if ( ( mretv & MENU_ENTRY_DELETE ) && selected_line < rmpd->cmd_list_length ) {
if ( selected_line < rmpd->history_length ) {

View file

@ -209,4 +209,3 @@ Mode *script_switcher_parse_setup ( const char *str )
script_switcher_free ( sw );
return NULL;
}

View file

@ -734,4 +734,3 @@ Mode window_mode_cd =
};
#endif // WINDOW_MODE

View file

@ -73,9 +73,9 @@ struct xkb_stuff xkb = {
.keymap = NULL,
.state = NULL,
.compose = {
.table = NULL,
.state = NULL
}
.table = NULL,
.state = NULL
}
};
char *config_path = NULL;
// Array of modi.
@ -344,7 +344,7 @@ static int add_mode ( const char * token )
}
else
#endif // WINDOW_MODE
// SSh dialog
// SSh dialog
if ( strcasecmp ( token, "ssh" ) == 0 ) {
modi[num_modi] = &ssh_mode;
num_modi++;
@ -456,22 +456,22 @@ static gboolean main_loop_x11_event_handler ( xcb_generic_event_t *ev, G_GNUC_UN
xkb.state = xkb_x11_state_new_from_device ( xkb.keymap, xcb->connection, xkb.device_id );
break;
case XCB_XKB_STATE_NOTIFY:
{
xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *) ev;
guint modmask;
xkb_state_update_mask ( xkb.state,
ksne->baseMods,
ksne->latchedMods,
ksne->lockedMods,
ksne->baseGroup,
ksne->latchedGroup,
ksne->lockedGroup );
modmask = x11_get_current_mask ( &xkb );
if ( modmask == 0 ) {
abe_trigger_release ( );
}
break;
{
xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *) ev;
guint modmask;
xkb_state_update_mask ( xkb.state,
ksne->baseMods,
ksne->latchedMods,
ksne->lockedMods,
ksne->baseGroup,
ksne->latchedGroup,
ksne->lockedGroup );
modmask = x11_get_current_mask ( &xkb );
if ( modmask == 0 ) {
abe_trigger_release ( );
}
break;
}
}
return G_SOURCE_CONTINUE;
}

View file

@ -102,4 +102,3 @@ static void separator_draw ( widget *wid, cairo_t *draw )
cairo_stroke ( draw );
}
}