1. #!/bin/bash
  2.  
  3. # mfk
  4. #
  5. # usage: toggle-xterm COMMAND
  6. #
  7. # if COMMAND is running in an xterm close the term; otherwise start  COMMAND in
  8. # an xterm.
  9. #
  10. # requires wmctrl
  11.  
  12. title="|> $@ <|"
  13. if wmctrl -l | grep "$title" >/dev/null ; then
  14.     wmctrl -F -c "$title"
  15. else
  16.     xterm -T "$title" -e $@ &
  17. fi