--- a/extsay-ng/extsayng.c Sat Apr 03 00:50:17 2010 +0200
+++ b/extsay-ng/extsayng.c Sat Apr 03 12:19:14 2010 +0200
@@ -44,26 +44,42 @@
.next = NULL,
};
-// Forks and run the external helper script
+
+// Run the external helper script with parameters
static void screen_run_script(const gchar *args)
{
GError *err = NULL;
- gchar *argv[] = { "screen", "-r", "-X", "screen", NULL, NULL, NULL };
+ gchar *argv[] = { "screen", "-r", "-X", "screen", NULL,
+ NULL, NULL, NULL, NULL };
gboolean ret;
+ gchar strwinheight[32];
+ gboolean winsplit = settings_opt_get_int("extsay_split_win");
- // screen -r -X screen $path/extsay.sh
+ // screen -r -X screen $path/extsay.sh [jid [winsplit [height]]]
argv[4] = (gchar*)settings_opt_get("extsay_script_path");
+ // Helper script path
if (!argv[4] || !argv[4][0]) {
scr_log_print(LPRINT_NORMAL, "Please set option 'extsay_script_path'.");
return;
}
+ // Helper script parameter #1
if (args && *args)
argv[5] = (gchar*)args;
else
argv[5] = ".";
+ // Update environment variables for the helper script
+ if (winsplit) {
+ gint winheight = settings_opt_get_int("extsay_win_height");
+ argv[6] = "winsplit"; // Helper script parameter #2
+ if (winheight > 0 && winheight < 256) {
+ snprintf(strwinheight, sizeof strwinheight, "%d", winheight);
+ argv[7] = strwinheight; // Helper script parameter #3
+ }
+ }
+
ret = g_spawn_async(NULL, argv, NULL,
G_SPAWN_SEARCH_PATH |
G_SPAWN_STDOUT_TO_DEV_NULL|G_SPAWN_STDERR_TO_DEV_NULL,