I have just checked in the new command ModuleListenOnly.  It works
like Module, but fvwm does not send any messages to such a module.

I am using it to attach a shell script to the module interface
that periodically updates titles of FvwmButtons to display a clock
(in the format I prefer, xclock is too stupid) and the process
that currently consumes most cpu.  The setup looks like this:

  AddToFunc InitFunction
  + I ModuleListenOnly /home/users/bin/fvwm_periodic \
    -u 15 -d 3 -c clock -t topproc

  AddToFunc RestartFunction
  + I ModuleListenOnly /home/users/bin/fvwm_periodic \
    -u 15 -d 3 -c clock -t topproc

  *FvwmButtons(11x1+30+0, Colorset 8, Id clock, Title " ", Action nop)
  *FvwmButtons(12x1+29+4, Colorset 8, Id topproc, Title " ", Action nop)

(zsh script attached).

Ciao

Dominik ^_^  ^_^

 --
Dominik Vogt, [EMAIL PROTECTED]
#!/usr/bin/zsh

emulate zsh
setopt HUP
zmodload zsh/zselect
[EMAIL PROTECTED]

MODULE="FvwmButtons"
IDCLOCK=""
IDPROC=""
SECS="15"
ISECS="3"

usage () {
        echo "usage: module-args $0 [-c id] [-t id] [-m module] [-u secs] [-d 
delay]"
        echo "Update certain button titles in FvwmButtons"
        echo " module-args:  filled out by fvwm when started as a module"
        echo " -h:           display this help message"
        echo " -c buttonid:  update clock at the given button id"
        echo " -t buttonid:  update topproc at the given button id"
        echo " -m module:    name of the module [$MODULE]"
        echo " -u secs:      update buttons every secs seconds [$SECS]"
        echo " -d secs:      initial delay [$ISECS]"
}

send ()
{
        printf \\00\\00\\00\\00\\0240\\00\\00\\00%159s\\00\\00\\00\\00\\n \
                "$1" >&$OF
}

#
# parse options
#

if test $# -le 4 && echo "fvwm_periodic must be started by fvwm" 1>&2 && exit 1
OF="$1"
IF="$2"
shift 5
while test ! $# = 0; do
        case "$1" in
        -h|-\?|--help)
                usage
                exit 0
                ;;
        -c|--clock)
                test $# = 1 && usage && exit 1
                shift
                IDCLOCK="$1"
                test ! x"$IDCLOCK" = x && zmodload zsh/datetime
                ;;
        -t|--topproc)
                test $# = 1 && usage && exit 1
                shift
                IDPROC="$1"
                ;;
        -m|--module-name)
                test $# = 1 && usage && exit 1
                shift
                MODULE="$1"
                test x"$MODULE" = x && usage && exit 1
                ;;
        -u|--update-secs)
                test $# = 1 && usage && exit 1
                shift
                SECS="$1"
                SECS="$[SECS]"
                test "$[SECS]" -le 0 && usage && exit 1
                ;;
        -d|--delay-secs)
                test $# = 1 && usage && exit 1
                shift
                ISECS="$1"
                ISECS="$[ISECS]"
                test "$[ISECS]" -le 0 && usage && exit 1
                ;;
        **)
                break
                ;;
        esac
        shift
done

if test ! $[$# > 1] = 0; then
        usage
        echo "error: unknown option $1"
        exit 1
fi


#
# main body
#

trap 0 1 2 3 9 13 15 exit

function update_proc ()
{
        local C
        local P
        local N

        ps -A --format "%C %P %c" | sort -n -r | read C P N
        send "SendToModule '$MODULE' ChangeButton '$IDPROC' Title '$P $C% $N'"
}

function update_clock ()
{
        local T

        T=`strftime '%R  %a %d.%m.' $EPOCHSECONDS`
        send "SendToModule '$MODULE' ChangeButton '$IDCLOCK' Title '$T'"
}

send "SET_MASK 0"
send "SET_MASK 2147483647"
S="$ISECS"
while true; do
        repeat "$S"; do
                zselect -t 100
        done
        S="$SECS"
        test ! x"$IDCLOCK" = x && update_clock
        test ! x"$IDPROC" = x && update_proc
done

Attachment: signature.asc
Description: Digital signature

Reply via email to