#!/bin/sh LOGFILE="${HOME}/.ltsp/log/msg.log" BINDIR="/usr/local/bin" FIFO="/srv/ltsp/msg/${USER}.fifo" TITLE="Incoming message" DEBUG=1 mkdir -p ${HOME}/.ltsp/log ################################################################################ function log() { if [ $1 -ge 1 ] ; then printf "%s: %s\n" "`date +%Y%m%d%H%M`" "${2}" >> ${LOGFILE} fi } function read_config() { if [ -e "${1}" ] ; then log ${DEBUG} "Reading ${1}" . ${1} else log ${DEBUG} "${1} not found" fi } # These are required for the Notify function function msg_other { log ${DEBUG} "xmessage -buttons '' -title \"${TITLE}\" -timeout ${TIMEOUT} -geometry 300x25-0+0 \"${1}\"" xmessage -buttons '' -title "${TITLE}" -timeout ${TIMEOUT} -geometry 300x25-0+0 "${1}" return $? } function msg_gnome210 { log ${DEBUG} "Using the gnome backends, timeout is not used" log ${DEBUG} "zenity --title \"${TITLE}\" --info --info-text \"${1}\"" zenity --title "${TITLE}" --info --info-text "${1}" return $? } function msg_kdeold { log ${DEBUG} "Using the old kde backend, timeout is not used" log ${DEBUG} "kdialog --title \"${TITLE}\" --msgbox \"${1}\"" kdialog --title "${TITLE}" --msgbox "${1}" return $? } function msg_kde34 { log ${DEBUG} "kdialog --title \"${TITLE}\" --passivepopup \"$1\" ${TIMEOUT}" kdialog --title "${TITLE}" --passivepopup "$1" ${TIMEOUT} return $? } function msg { log ${DEBUG} "${1}" msg_${WM} "${1}" > /dev/null 2>&1 RVAL=$? if [ ${RVAL} != 0 ] ; then log ${DEBUG} "msg_${WM} failed, using msg_other" msg_other "$1" RVAL=$? fi return ${RVAL} } # Read in configuration, user overrides system read_config /etc/ltsp/msg.conf read_config ${HOME}/.ltsp/msg.conf # Defaults WM=${WM:-"other"} TIMEOUT=${TIMEOUT:-"10"} TIMEOUT=${TIMEOUT:-"10"} log ${DEBUG} "WM : ${WM}" log ${DEBUG} "FIFO: ${FIFO}" if [ ! -p "${FIFO}" ] ; then log ${DEBUG} "Creating FIFO" mkfifo ${FIFO} chmod 660 ${FIFO} fi while [ 1 ] ; do MESSAGE="`cat ${FIFO}`" msg "${MESSAGE}" done exit 1