Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1 from wil-langford/master

Added a command-line argument and did some error trapping.
  • Loading branch information...
commit a34c5136dc85e1fd45763de1e46f9c44bf511ca2 2 parents 53e2a7e + d3a732f
@SirVer authored
Showing with 17 additions and 4 deletions.
  1. +17 −4 move_window
View
21 move_window
@@ -4,6 +4,7 @@
import argparse
import re
import subprocess
+from sys import exit
import _mw_helper
@@ -13,6 +14,8 @@ def parse_args():
parser = argparse.ArgumentParser(description='Move windows via AppleEvents')
parser.add_argument('cmd', type=str, default="0",
help='<screen=0><xratio=1><xpos=0[-ypos]><yratio=1><ypos=0[-ypos]>')
+ parser.add_argument('-L','--left-limit',type=int,default=0,dest='left_limit',
+ help='sets the left-hand limit (in pixels) so that windows do not get moved under a left-side dock')
return parser.parse_args()
@@ -37,6 +40,7 @@ def move_window(x, y, w, h):
def main():
cmd = parse_args().cmd
+ left_limit = parse_args().left_limit
res = _mw_helper.get_resolutions()
screen, cmd = (0, cmd) if not cmd else (int(cmd[0]), cmd[1:])
@@ -55,17 +59,26 @@ def main():
x, y = 0, 22
res[0][1] -= 22
else:
- x = -res[1][0]
- y = 0
+ try:
+ x = -res[1][0]
+ y = 0
+ left_limit = 0
+ except IndexError:
+ if len(res)<=screen:
+ print "Your screen(s):"
+ for residx in range(len(res)):
+ print " [{0}]: {1} x {2}".format(residx,res[residx][0],res[residx][1])
+ print "Tried to move window to screen {0}, but it does not exist.".format(screen)
+ exit()
assert(screen in [0,1])
- one_width = (res[screen][0] / xratio)
+ one_width = ((res[screen][0] - left_limit) / xratio)
one_height = (res[screen][1] / yratio)
w = one_width * (xpos_e - xpos_s + 1)
h = one_height * (ypos_e - ypos_s + 1)
- x += one_width * xpos_s
+ x += one_width * xpos_s + left_limit
y += one_height * ypos_s
move_window(x, y, w, h)
Please sign in to comment.
Something went wrong with that request. Please try again.