Advertisement
Guest User

scratchpad.sh

a guest
Nov 11th, 2012
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. X=200
  4. Y=200
  5. W=100
  6. H=30
  7. COMMAND="$SHELL"
  8.  
  9. if [ -n "$1" ]
  10. then
  11.     SNAME="$1";
  12.  
  13.     if [ -n "$2" ]
  14.     then
  15.         COMMAND="$2";
  16.        
  17.         if [ -n "$3" ]
  18.         then
  19.             X="$3";
  20.  
  21.             if [ -n "$4" ]
  22.             then
  23.                 Y="$4";
  24.                
  25.                 if [ -n "$5" ]
  26.                 then
  27.                     W="$5";
  28.  
  29.                     if [ -n "$6" ]
  30.                     then
  31.                         H="$6";
  32.                     fi
  33.                 fi
  34.             fi
  35.         fi
  36.     fi
  37. else
  38.     SNAME="";
  39. fi
  40.  
  41. PATNAME="\*-scratch-${SNAME}\*";
  42. TERMNAME="*-scratch-${SNAME}*";
  43.  
  44. SW=`xdotool search --classname ${PATNAME}`;
  45. if [ -z "$SW" ]
  46. then
  47.     urxvtc -name ${TERMNAME} -g "${W}x${H}+${X}+${Y}" -e "${COMMAND}";
  48.     SW=`xdotool search --classname ${PATNAME}`;
  49.     xdotool windowunmap "$SW";
  50.     xprop -id "$SW" -f _NET_WM_WINDOW_TYPE 32a -set _NET_WM_WINDOW_TYPE _NET_WM_WINDOW_TYPE_DIALOG
  51.     xdotool set_window --classname ${TERMNAME} --role '*-scratch-*' #--overrideredirect 0 "$SW"
  52.     xdotool windowmap "$SW"
  53.     xdotool windowraise "$SW" windowsize --usehints "$SW" "$W" "$H" windowmove "$SW" "$X" "$Y";
  54.     xdotool windowfocus "$SW";
  55.     #xdotool behave "$SW" mouse-enter windowfocus
  56.     #xprop -id "$SW" -f WM_WINDOW_ROLE 8s -set WM_WINDOW_ROLE '*-scratch-*'
  57.     #xprop -id "$SW" -f _NET_WM_STATE 32a -set _NET_WM_STATE _NET_WM_STATE_ABOVE
  58.     #xprop -id "$SW" -f _NET_WM_STATE 32a -set _NET_WM_STATE _NET_WM_STATE_SKIP_TASKBAR
  59.     #wmctrl -x -r ${TERMNAME} -b add,above,skip_taskbar
  60.     #wmctrl -x -r ${TERMNAME} -b remove,maximized_vert,maximized_horz
  61.     #wmctrl -x -r ${TERMNAME} -e 0,"$X,$Y,$W,$H";
  62. else
  63.  
  64.     SWN=`xdotool search --onlyvisible --classname ${PATNAME}`;
  65.     if [ -n "$SWN" ]
  66.     then
  67.         xdotool windowminimize "$SWN";
  68.         xdotool windowunmap "$SWN";
  69.         xdotool getactivewindow windowraise
  70.     else
  71.         xdotool windowmap "$SW";
  72.         xdotool windowraise "$SW" windowsize --usehints "$SW" "$W" "$H" windowmove "$SW" "$X" "$Y";
  73.     fi
  74.  
  75. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement