diff --git a/plugins/common/gsd-input-helper.c b/plugins/common/gsd-input-helper.c
index 06594e9..b73dcae 100644
--- a/plugins/common/gsd-input-helper.c
+++ b/plugins/common/gsd-input-helper.c
@@ -484,9 +484,10 @@ run_custom_command (GdkDevice              *device,
                     CustomCommand           command)
 {
         GSettings *settings;
+        GSubprocessContext *ctx;
+        GSubprocess *proc;
         char *cmd;
-        char *argv[7];
-        int exit_status;
+        char *deviceid_str;
         gboolean rc;
         int id;
 
@@ -502,24 +503,23 @@ run_custom_command (GdkDevice              *device,
         /* Easter egg! */
         g_object_get (device, "device-id", &id, NULL);
 
-        argv[0] = cmd;
-        argv[1] = "-t";
-        argv[2] = (char *) custom_command_to_string (command);
-        argv[3] = "-i";
-        argv[4] = g_strdup_printf ("%d", id);
-        argv[5] = (char*) gdk_device_get_name (device);
-        argv[6] = NULL;
-
-        rc = g_spawn_sync (g_get_home_dir (), argv, NULL, G_SPAWN_SEARCH_PATH,
-                           NULL, NULL, NULL, NULL, &exit_status, NULL);
-
-        if (rc == FALSE)
+        deviceid_str = g_strdup_printf ("%d", id);
+        ctx = g_subprocess_context_newl (cmd,
+                                         "-t", custom_command_to_string (command),
+                                         "-i", deviceid_str,
+                                         (char*)gdk_device_get_name (device),
+                                         NULL);
+        proc = g_subprocess_new (ctx, NULL);
+        g_object_unref (ctx);
+        if (!proc)
                 g_warning ("Couldn't execute command '%s', verify that this is a valid command.", cmd);
 
-        g_free (argv[0]);
-        g_free (argv[4]);
-
-        return (exit_status == 1);
+        g_free (cmd);
+        g_free (deviceid_str);
+        
+        if (proc)
+                return g_subprocess_wait_sync_check (proc, NULL, NULL);
+        return TRUE;
 }
 
 GList *
