#!/bin/sh
# window manager improved 2 run action

if [ $# -eq 0 ]; then
    echo "`basename $0`: error: missing argument(s)" >&2
    exit 1
fi

if [ -r "$HOME/.wmii/rc.conf" ]; then
    WMII_RCCONF="$HOME/.wmii/rc.conf"
elif [ -r "$WMII_CONFDIR/rc.conf" ]; then
    WMII_RCCONF="$WMII_CONFDIR/rc.conf"
else
    echo "`basename $0`: error: couldn't read rc.conf" >&2
    exit 2
fi
export WMII_RCCONF

action="$1"
shift
if [ -x "$HOME/.wmii/action/$action" ]; then
    exec "$HOME/.wmii/action/$action" "$@"
elif [ -x "$WMII_CONFDIR/action/$action" ]; then
    exec "$WMII_CONFDIR/action/$action" "$@"
else
    echo "`basename $0`: error: couldn't read $action" >&2
    exit 3
fi
