Much, much, much nicer, isn't it? The first difference is that our hardcoded process searching is replaced with a services array and a for loop. Then we have all of our music outputting routines done in functions. But here is where it gets a little confusing.

running=$(what_is_running)
${running}_fn

WTF? You just have a variable on its own? How the hell is that supposed to work? Well, it does! This is where bash's magic comes into play. With bash, variables are directly expanded into strings. And since ${running} is directly expanded, that line becomes mpd_fn or pianboar_fn or none_fn at runtime, and so instead of throwing an error like any other language would do, bash just calls the function!

Neat, huh? And you thought Ruby and Lisp were the only languages with metaprogramming!