This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 8th, 2013  |  syntax: Bash  |  size: 4.25 KB  |  views: 107  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash
  2. #############################################   CONFIGURATION   #############################################
  3.  
  4. PANEL_L=$((0))         # If panel is on the LEFT of the screen, set its height here. If there's no panel there, set it to 0.
  5. PANEL_R=$((0))         # If panel is on the RIGHT of the screen, set its height here. If there's no panel there, set it to 0.
  6. PANEL_T=$((0))         # If panel is on the TOP of the screen, set its height here. If there's no panel there, set it to 0.
  7. PANEL_B=$((40))         # If panel is on the BOTTOM of the screen, set its height here. If there's no panel there, set it to 0.
  8. WINDOW_BORDER=$((1))      # Set the window border according to the theme. If there's no window border, set it to 0.
  9. WINDOW_DECORATION=$((10)) # Set the window decoration border according to the theme. If there's no decoration, set it to 0.
  10.  
  11. #############################################  /CONFIGURATION   #############################################
  12.  
  13. # Print help:
  14. printUsage ()
  15. {
  16. echo -e "Invalid command line argument(s)!\nUsage:\n"
  17. echo -e "`basename "$0"` [options]\n"
  18. echo -e "Options:\n"
  19. echo -e "-l  | --left    \tPut the window to the left"
  20. echo -e "-r  | --right    \tPut the window to the right"
  21. echo -e "-t  | --top    \tPut the window to the top"
  22. echo -e "-tl | --top-left\tPut the window to the top-left corner"
  23. echo -e "-tr | --top-right\tPut the window to the top-right corner"
  24. echo -e "-bl | --bottom-left\tPut the window to the bottom left corner"
  25. echo -e "-br | --bottom-right\tPut the window to the bottom right corner"
  26. echo -e " "
  27. echo -e "Win_tile 0.2b by Slug.45 2011"
  28. exit 1
  29. }
  30.  
  31. # Get Screen resolution:
  32. RES_Y=`xwininfo -root | grep Height | awk '{ print (($2))}'`
  33. RES_X=`xwininfo -root | grep Width | awk '{ print (($2))}'`
  34.  
  35. # Functions:
  36. ## LEFT
  37. if [ "$#" == "1" ]; then
  38. case "$1" in
  39. "-l" | "--left")
  40. POS_X=$((PANEL_L))
  41. POS_Y=$((PANEL_T))
  42. SIZE_X=$((RES_X/2-PANEL_L/2-PANEL_R/2-WINDOW_BORDER))
  43. SIZE_Y=$((RES_Y-PANEL_T-PANEL_B-WINDOW_DECORATION))
  44. wmctrl -r :ACTIVE: -e 0,$POS_X,$POS_Y,$SIZE_X,$SIZE_Y
  45. exit 0
  46. ;;
  47. ## RIGHT
  48. "-r" | "--right")
  49. POS_X=$((RES_X/2))
  50. POS_Y=$((PANEL_T))
  51. SIZE_X=$((RES_X/2-PANEL_L/2-PANEL_R/2-WINDOW_BORDER))
  52. SIZE_Y=$((RES_Y-PANEL_T-PANEL_B-WINDOW_DECORATION))
  53. wmctrl -r :ACTIVE: -e 0,$POS_X,$POS_Y,$SIZE_X,$SIZE_Y
  54. exit 0
  55. ;;
  56. ## TOP LEFT
  57. "-tl" | "--top-left")
  58. POS_X=$((PANEL_L))
  59. POS_Y=$((PANEL_T))
  60. SIZE_X=$((RES_X/2-PANEL_L/2-PANEL_R/2-WINDOW_BORDER))
  61. SIZE_Y=$((RES_Y/2-PANEL_T/2-PANEL_B/2-WINDOW_DECORATION))
  62. wmctrl -r :ACTIVE: -e 0,$POS_X,$POS_Y,$SIZE_X,$SIZE_Y
  63. exit 0
  64. exit 0
  65. ;;
  66. ## TOP RIGHT
  67. "-tr" | "--top-right")
  68. POS_X=$((RES_X/2+PANEL_L/2-PANEL_R/2))
  69. POS_Y=$((PANEL_T))
  70. SIZE_X=$((RES_X/2-PANEL_L/2-PANEL_R/2-WINDOW_BORDER))
  71. SIZE_Y=$((RES_Y/2-PANEL_T/2-PANEL_B/2-WINDOW_DECORATION))
  72. wmctrl -r :ACTIVE: -e 0,$POS_X,$POS_Y,$SIZE_X,$SIZE_Y
  73. exit 0
  74. exit 0
  75. ;;
  76. ## BOTTOM LEFT
  77. "-bl" | "--bottom-left")
  78. POS_X=$((PANEL_L))
  79. POS_Y=$((RES_Y/2+PANEL_T/2-PANEL_B/2))
  80. SIZE_X=$((RES_X/2-PANEL_L/2-PANEL_R/2-WINDOW_BORDER))
  81. SIZE_Y=$((RES_Y/2-PANEL_T/2-PANEL_B/2-WINDOW_DECORATION))
  82. wmctrl -r :ACTIVE: -e 0,$POS_X,$POS_Y,$SIZE_X,$SIZE_Y
  83. exit 0
  84. exit 0
  85. ;;
  86. ## BOTOM RIGHT
  87. "-br" | "--bottom-right")
  88. POS_X=$((RES_X/2+PANEL_L/2-PANEL_R/2))
  89. POS_Y=$((RES_Y/2+PANEL_T/2-PANEL_B/2))
  90. SIZE_X=$((RES_X/2-PANEL_L/2-PANEL_R/2-WINDOW_BORDER))
  91. SIZE_Y=$((RES_Y/2-PANEL_T/2-PANEL_B/2-WINDOW_DECORATION))
  92. wmctrl -r :ACTIVE: -e 0,$POS_X,$POS_Y,$SIZE_X,$SIZE_Y
  93. exit 0
  94. exit 0
  95. ;;
  96. ## TOP
  97. "-t" | "--top")
  98. POS_X=$((PANEL_L))
  99. POS_Y=$((PANEL_T))
  100. SIZE_X=$((RES_X-PANEL_L/2-PANEL_R/2-WINDOW_BORDER))
  101. SIZE_Y=$((RES_Y/2-PANEL_T/2-PANEL_B/2-WINDOW_DECORATION))
  102. wmctrl -r :ACTIVE: -e 0,$POS_X,$POS_Y,$SIZE_X,$SIZE_Y
  103. exit 0
  104. exit 0
  105. ;;
  106. ## BOTTOM
  107. "-b" | "--bottom")
  108. POS_X=$((PANEL_L))
  109. POS_Y=$((RES_Y/2+PANEL_T/2-PANEL_B/2))
  110. SIZE_X=$((RES_X-PANEL_L/2-PANEL_R/2-WINDOW_BORDER))
  111. SIZE_Y=$((RES_Y/2-PANEL_T/2-PANEL_B/2-WINDOW_DECORATION))
  112. wmctrl -r :ACTIVE: -e 0,$POS_X,$POS_Y,$SIZE_X,$SIZE_Y
  113. exit 0
  114. exit 0
  115. ;;
  116. ## MAX
  117. "-m" | "--maximize")
  118. POS_X=$((PANEL_L))
  119. POS_Y=$((PANEL_T))
  120. SIZE_X=$((RES_X-PANEL_L/2-PANEL_R/2-WINDOW_BORDER))
  121. SIZE_Y=$((RES_Y-PANEL_T-PANEL_B-WINDOW_DECORATION))
  122. wmctrl -r :ACTIVE: -e 0,$POS_X,$POS_Y,$SIZE_X,$SIZE_Y
  123. exit 0
  124. exit 0
  125. ;;
  126. *)
  127. printUsage
  128. exit 1
  129. ;;
  130. esac
  131. else
  132. printUsage
  133. exit 1
  134. fi
clone this paste RAW Paste Data