summaryrefslogtreecommitdiffstats
path: root/source/dialogs
diff options
context:
space:
mode:
authorQuentin Glidic <sardemff7+git@sardemff7.net>2016-05-12 11:31:06 +0200
committerQuentin Glidic <sardemff7+git@sardemff7.net>2016-05-12 11:31:12 +0200
commitdb4f08748741813e03aa83177be9825f6d068c00 (patch)
tree97d12f8f130799e00be74465a2379c01b426de73 /source/dialogs
parent3bd41b9a419fcf01250d614d1e05c8a79576dcd8 (diff)
window: Make custom action run a command on the window
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Diffstat (limited to 'source/dialogs')
-rw-r--r--source/dialogs/window.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/source/dialogs/window.c b/source/dialogs/window.c
index 2a9cedb0..5e5dd63e 100644
--- a/source/dialogs/window.c
+++ b/source/dialogs/window.c
@@ -526,6 +526,34 @@ static int window_mode_init_cd ( Mode *sw )
}
return TRUE;
}
+
+static inline int act_on_window ( xcb_window_t window )
+{
+ int retv = TRUE;
+ char **args = NULL;
+ int argc = 0;
+ char window_str[100]; /* We are probably safe here */
+
+ g_snprintf(window_str, sizeof window_str, "%d", window);
+
+ helper_parse_setup ( config.window_command, &args, &argc, "{window}", window_str, 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 action for window: '%s'\nError: '%s'", window_str, 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;
+}
+
static ModeMode window_mode_result ( Mode *sw, int mretv, G_GNUC_UNUSED char **input,
unsigned int selected_line )
{
@@ -541,7 +569,10 @@ static ModeMode window_mode_result ( Mode *sw, int mretv, G_GNUC_UNUSED char **i
retv = ( mretv & MENU_LOWER_MASK );
}
else if ( ( mretv & ( MENU_OK ) ) && rmpd->cmd_list[selected_line] ) {
- if ( rmpd->config_i3_mode ) {
+ if ( mretv & MENU_CUSTOM_ACTION ) {
+ act_on_window ( rmpd->ids->array[selected_line] );
+ }
+ else if ( rmpd->config_i3_mode ) {
// Hack for i3.
i3_support_focus_window ( rmpd->ids->array[selected_line] );
}