Focus window by name using xdotool and awesome window manager

I have two screens, and 9 virtual dekstops on my machines. Which sometimes makes it tricy to remember on which virtual desktop is xterm connected to klin. Fortunatly, I have that information in window title, so something as simple as:

xdotool search --name klin windowactivate
Will do the right thing. However, my mouse pointer is not always over xterm on local machine, so keyboard shortcut in awesome window manager for this simple xdotool usage would be helpful. So, here it is:
-- XXX dpavlin: search windows and active them
awful.key({ modkey }, "F12",
  function (){ prompt = "window: " },
      function (find)
        awful.util.spawn("xdotool search --name "..find.." windowactivate", false)

I would love to be able to insert this snippet somehow dynamically instead of editing rc.lua by hand, so suggestions are welcomed.