clockworkpc

Unity 2D Snap Windows

Apr 1st, 2012
957
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2. #/home/cpcmonster/bin/unity2dsnapsetup.py
  3.  
  4. # Released under a GPLv3 Licence by Clockwork PC 2011
  5. # www.clockworkpc.com.au
  6.  
  7. # You are entitled to the following four freedoms:
  8. # Freedom 0: To run this program for any purpose
  9. # Freedom 1: To study how this program works and change it to make it do what you wish
  10. # Freedom 2: To redistribute copies so you can help your neighbour
  11. # Freedom 3: To distribute copies of your modified version to others
  12.  
  13. import os
  14.  
  15. binFolder = os.getenv("HOME")+"/bin/"
  16.  
  17. snapLeftText = "wmctrl -r :ACTIVE: -e 0,0,0,840,1000"
  18. snapRightText = "wmctrl -r :ACTIVE: -e 0,840,0,840,1000"
  19. snapLeftName = "unity2dsnapleft.sh"
  20. snapRightName = "unity2dsnapright.sh"
  21. snapLeftFile = binFolder + "unity2dsnapleft.sh"
  22. snapRightFile = binFolder + "unity2dsnapright.sh"
  23.  
  24. print binFolder
  25. print snapLeftFile
  26. print snapRightFile
  27.  
  28. os.system("touch " + snapLeftFile)
  29. os.system("touch " + snapRightFile)
  30.  
  31. f = open(snapLeftFile, "a")
  32. f.write("""#!/bin/bash
  33. #~/bin/unity2dsnapleft.sh
  34. """ + snapLeftText)
  35. f.close
  36.  
  37. g = open(snapRightFile, "a")
  38. g.write("""#!/bin/bash
  39. #~/bin/unity2dsnapright.sh
  40. """ + snapRightText)
  41. g.close
  42.  
  43. os.system("chmod +x " + snapLeftFile)
  44. os.system("chmod +x " + snapRightFile)
  45. os.system("sudo ln -sv " + snapLeftFile + " " + "/usr/local/bin/"+snapLeftName)
  46. os.system("sudo ln -sv " + snapRightFile + " " + "/usr/local/bin/"+snapRightName)
  47.  
  48. #Then you have to assign the keyboard shortcuts accordingly.  
  49. #ALT+SHIFT+LEFT = snap left
  50. #ALT+SHIFT+RIGHT = snap right
  51.  
  52. os.sytem("sudo apt-get install wmctrl")
RAW Paste Data