SHARE
TWEET

urukrama

a guest May 5th, 2008 702 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2.  
  3. thunar_wm_class="thunar"
  4. thunar_exec="thunar"
  5.  
  6. # no thunar started, so start one
  7. if [ -z "`wmctrl -lx | grep thunar`" ]; then
  8.     $thunar_exec &
  9. else
  10.     # search for existing thunars on current desktop
  11.     current_desk=`wmctrl -d | grep '*' | cut -d ' ' -f 1`
  12.     thunar_on_this_desk=`wmctrl -lx | grep "$current_desk[ ]*$thunar_wm_class" | cut -d ' ' -f 1`
  13.     if [ -n "$thunar_on_this_desk" ]; then
  14.         wmctrl -i -a $thunar_on_this_desk
  15.     else
  16.         # no thunars on current desktop, so open a new one
  17.         wmctrl -x -R $thunar_wm_class
  18.     fi;
  19. fi;
RAW Paste Data
Want to get better at Bash?
Learn to code Bash in 2017
Top