extsay-ng/extsay.sh
changeset 24 81cbb47f1aa6
parent 23 cf95a475825c
child 27 4f1cbafb569c
--- a/extsay-ng/extsay.sh	Sat Apr 03 00:50:17 2010 +0200
+++ b/extsay-ng/extsay.sh	Sat Apr 03 12:19:14 2010 +0200
@@ -5,8 +5,10 @@
 # Copy this script on your system and specify the path for mcabber
 # by setting the 'extsay_script_path' option.
 #
+# Usage: extsay.sh [jid [winsplit [height]]]
+#
 # This script is free software.
-# MiKael, 2010-04-02
+# MiKael, 2010-04-03
 
 FIFOPATH="$HOME/.mcabber/mcabber.fifo"
 
@@ -17,12 +19,23 @@
 jid="."
 
 # Use argument as a recipient JID, if it is provided
-[ $# -eq 1 ] && jid=$1
+[ $# -ge 1 ] && jid=$1
+[ $# -ge 2 ] && winsplit=$2
+[ $# -ge 3 ] && winheight=$3
 
 # Leave if the FIFO is not available
 [ -p $FIFOPATH ] || exit 255
 
-tf=$(mktemp $tmpdir/extsay-XXXXXX) || exit 255
+tf=$(mktemp $tmpdir/extsay-$jid-XXXXXX) || exit 255
+
+if [ x$winsplit = x"winsplit" ]; then
+    screen -r -X other
+    screen -r -X split
+    screen -r -X focus down
+    screen -r -X other
+
+    [ $winheight -gt 0 ] && screen -r -X resize $winheight
+fi
 
 # This will not work if the editor runs in the background!
 $editor $tf
@@ -35,6 +48,10 @@
 fi
 echo $cmd >> $FIFOPATH
 
+if [ x$winsplit = x"winsplit" ]; then
+    screen -r -X remove
+fi
+
 # Do not remove the file too soon
 setsid sh -c "cd / && sleep 20 && rm $tf & :" /dev/null 2>&1 < /dev/null