SHARE
TWEET

sole_terminal

a guest May 5th, 2008 617 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2.  
  3. terminal_wm_class="Terminal"
  4. terminal_exec="Terminal"
  5.  
  6. # no terminal started, so start one
  7. if [ -z "`wmctrl -lx | grep Terminal`" ]; then
  8.     $terminal_exec &
  9. else
  10.     # search for existing terminals on current desktop
  11.     current_desk=`wmctrl -d | grep '*' | cut -d ' ' -f 1`
  12.     term_on_this_desk=`wmctrl -lx | grep "$current_desk[ ]*$terminal_wm_class" | cut -d ' ' -f 1`
  13.     if [ -n "$term_on_this_desk" ]; then
  14.         wmctrl -i -a $term_on_this_desk
  15.     else
  16.         # no terminals on current desktop, so just open a new one
  17.         wmctrl -x -R $terminal_wm_class
  18.     fi;
  19. fi;
RAW Paste Data
Top