#!/bin/sh
title='Beer-O-Meter'
accounts='./accounts'
+totals="$accounts/.totals"
backend='./audio.sh'
tmp="/tmp/beertmp-$$";
dialog=$(which dialog);
add_account
;;
exit)
+ clear
+ echo "=== Totals ($totals) ==="
+ echo
+ cat "$totals"
+ echo
exit
;;
esac
}
beer_menu() {
- echo -n > "$accounts/.totals"
+ echo -n > "$totals"
ls -1 --group-directories-first "$accounts" | while read i; do
echo -n "$i"; echo -ne "\x00";
echo -n $(beer_stat "$i"); echo -ne "\x00"
- echo -e "$i\t$(beer_stat "$i")" >> "$accounts/.totals"
+ echo -e "$i\t$(beer_stat "$i")" >> "$totals"
done | xargs -0 $dialog --menu "$title stamgasti" 0 0 0
}
beer_menu 2>"$tmp"
[ "$?" = "0" ] && {
stamgast="$(cat "$tmp")"
+ clear
echo == Cepuje stamgast $stamgast, ukonci ctrl+c ==
"$backend" | tee -a "$accounts/$stamgast"
true