Re: [dev] [wmii] problem with wmiir xwrite /client/$client/ctl kill

From: Thomas Dean <78abc_AT_web.de>
Date: Thu, 27 May 2010 11:22:25 +0200

I ran into the same problem today. The wmiirc script as well as all my
status bar scripts die frequently. All of them are run with dash.
Switching /bin/sh from dash to bash (and replacing dash with bash in
wmiirc) fixes the problem. It seems to be related to the latest update
of dash (0.5.5.1-5) in Debian.

One example is the attached script, which shows my mail count, and
shows ~/.fetchmaillog on a right click. Strangely, the script survives
multiple right clicks (the file is shown in multiple windows), but
dies as soon as one of those windows is closed, either via C-c, or via
Mod-Shift-c.

-----------------------------------------------------

#!/bin/sh
# show email information in the status bar

# Configuration
delay=10
barname="8-mail"
maildir="$HOME/.Maildir"

# Functions
mailcount() {
        echo -n `ls -l $@ | grep ^- | wc -l`
}

output() {
        echo -n Mail `mailcount $maildir/new` `mailcount $maildir/.Lists*/new`
}

# Trigger event such that previous instances can quit
echo Start $barname | wmiir write /event

# Create bar with content
echo "$WMII_BARCOLORS" | wmiir create /rbar/$barname
wmiir xwrite /rbar/"$barname" `output`

# Event loop
{ wmiir read /event & childpid=$!
  while true; do
          echo "$barname" `output` || { kill $childpid; exit; }
          sleep $delay
  done &
} | while read event
do
        set -f
        set -- $event
        set +f
        type="$1"; shift
        case "$type" in
        # Exit if another instance starts up
        Start)
                if test "$1" = "$barname"; then
                        break
                fi;;
        # Write output to bar. If that fails, exit.
        "$barname")
                wmiir xwrite /rbar/$barname "$@" || exit;;
        # React to clicks on our bar
        RightBarClick)
                if test "$2" = "$barname"; then
                        case "$1" in
                        1)
                                fetchmail &;;
                        3)
                                x-terminal-emulator -e tail -n 200 -f ~/.fetchmaillog &;;
                        esac
                fi;;
        esac
done
Received on Thu May 27 2010 - 09:22:25 UTC

This archive was generated by hypermail 2.2.0 : Thu May 27 2010 - 10:00:03 UTC