From The Compiler, 6 Years ago, written in Bash.
Embed
  1. #!/bin/bash
  2.  
  3. name="ncmpcpp"
  4. bin="$name"
  5.  
  6. for w in $(xprop -root | sed -n '/^_NET_CLIENT_LIST(WINDOW):/{s/.*# //;s/,//g;p}'); do
  7.     if xprop -id "$w" | grep -q "^WM_CLASS(STRING) = \"$name\""; then
  8.         herbstclient jumpto "$w"
  9.         exit 0
  10.     fi
  11. done
  12.  
  13. # If we are here, it's not running
  14. urxvt -name "$name" -e "$bin"