extsay-ng/extsay.sh
changeset 22 b6b45c2eb022
parent 21 9798e3aaa851
child 23 cf95a475825c
equal deleted inserted replaced
21:9798e3aaa851 22:b6b45c2eb022
     7 #
     7 #
     8 # This script is free software.
     8 # This script is free software.
     9 # MiKael, 2010-04-02
     9 # MiKael, 2010-04-02
    10 
    10 
    11 FIFOPATH="$HOME/.mcabber/mcabber.fifo"
    11 FIFOPATH="$HOME/.mcabber/mcabber.fifo"
    12 tmpdir=${TMPDIR:="/tmp"}
    12 
       
    13 tmpdir=${TMPDIR:=$TMP}
       
    14 tmpdir=${tmpdir:="/tmp"}
    13 editor=${EDITOR:="vi"}
    15 editor=${EDITOR:="vi"}
       
    16 
    14 jid="."
    17 jid="."
    15 
    18 
    16 # Use argument as a recipient JID, if it is provided
    19 # Use argument as a recipient JID, if it is provided
    17 [ $# -eq 1 ] && jid=$1
    20 [ $# -eq 1 ] && jid=$1
    18 
    21 
    19 # Leave if the FIFO is not available
    22 # Leave if the FIFO is not available
    20 [ -p $FIFOPATH ] || exit 255
    23 [ -p $FIFOPATH ] || exit 255
    21 
    24 
    22 tf=$(mktemp --tmpdir=$tmpdir extsay-XXXXXX) || exit 255
    25 tf=$(mktemp $tmpdir/extsay-XXXXXX) || exit 255
    23 
    26 
    24 # This will not work if the editor runs in the background!
    27 # This will not work if the editor runs in the background!
    25 $editor $tf
    28 $editor $tf
    26 
    29 
    27 # Send the message using MCabber's pipe
    30 # Send the message using MCabber's pipe
    28 if [ -s $tf ]; then
    31 if [ -s $tf ]; then
    29     cmd="say_to -f $tf $jid"
    32     cmd="say_to -f $tf $jid"
    30     echo $cmd >> $FIFOPATH
    33     echo $cmd >> $FIFOPATH
    31 fi
    34 fi
    32 
    35 
    33 rm $tf
    36 # Do not remove the file too soon
       
    37 (sleep 20 ; rm $tf)&
       
    38 
    34 exit 0
    39 exit 0