ambevar-dotfiles/.local/bin/winefps

30 lines
622 B
Bash
Executable File

#!/bin/sh
usage () {
cat <<EOF>&2
Usage: ${0##*/} WIN_EXE PARAMS"
Run Wine application while displaying FPS onscreen.
EOF
}
[ $# -eq 0 ] && usage && exit 1
[ "$1" = "-h" ] && usage && exit
[ "$1" = "--" ] && shift
if ! command -v osd_cat >/dev/null 2>&1; then
echo >&2 "osd_cat not found"
exit 1
fi
## The unbuffered option is -u on GNU and OpenBSD, -l on others.
OPT_UNBUF=-l
case "$(uname)" in
Linux|OpenBSD) OPT_UNBUF=-u ;;
esac
WINEDEBUG=fps wine "$@" 2>&1 | tee /dev/stderr | \
sed $OPT_UNBUF -n '/^trace:fps:/{s/.* \([^ ]*\)fps/\1/;p}' | \
osd_cat -l1 -f "-*-*-*-*-*-*-32-*-*-*-*-*-*-*" -O1 -c "yellow"