#!/usr/local/bin/nawk -f function quit() { system("rm -f " tmpfile) exit } BEGIN { FS = "\t+" n = 0 while ((getline < (ENVIRON["HOME"] "/.shoutrc")) > 0) { title[n] = $1 url[n++] = $2 } if (! n) { print "No stations found" exit } if (("mktemp ~/.scmenu.XXXXXX" | getline tmpfile) == 0) exit for (i = 0; i < n; i++) printf "%3d: %s\n", i + 1, title[i] > tmpfile while (1) { system("less " tmpfile) do { err = 0 printf "Station ([s]1-" n "), 0 to exit: " if ((getline < "/dev/tty") <= 0) quit() status = 0 if (sub(/^s/, "")) status = 1 r = ($0 ~ /^[0-9]+$/) ? $0 : -1 if (r == 0) quit() if ((r < 0) || (r > n)) { print "Error: invalid response" err++ } } while (err) u = url[r - 1] if (status) system("lynx '" u "'") else system("nohup xmms '" u "' > /dev/null &") } } .