#! /bin/bash
# Filename: ~/.local/share/nautilus/scripts/word-count

# I, the Copyright holder of this work, hereby release it into the Public
# Domain. This applies worldwide. In case this is not legally possible, I
# grant anyone the right to use this work for any purpose, without any
# conditions, unless such conditions are required by law.
#
# 2009 Timothy Richard Musson <trmusson@gmail.com>

PROG=$(basename $0)

if [ "$1" = '-h' ]; then
  echo "Usage: $PROG FILE..."
  exit 0
fi

if command -v gxmessage >/dev/null 2>&1; then
    XMESSAGE=gxmessage
else
    XMESSAGE=xmessage
fi

font=monospace
[ "$XMESSAGE" = xmessage ] && font=fixed

[ "$#" -ge 1 ] &&
  wc "$@" 2>&1 | $XMESSAGE ${font:+-fn "$font"}     \
                         -title "$PROG"             \
                         -nearmouse                 \
                         -buttons Close:0           \
                         -default Close             \
                         -file -

