diff --git a/DockPhobia/Info.plist b/DockPhobia/Info.plist index d1a5b03..cbe6779 100644 --- a/DockPhobia/Info.plist +++ b/DockPhobia/Info.plist @@ -6,7 +6,8 @@ allow it NSAccessibilitysUsageDescription allow it - + com.apple.security.automation.apple-events<> + com.apple.security.scripting-targets com.apple.mail diff --git a/DockPhobiaPy/main.py b/DockPhobiaPy/main.py index 19b3d3e..53af212 100644 --- a/DockPhobiaPy/main.py +++ b/DockPhobiaPy/main.py @@ -2,16 +2,17 @@ from pynput.mouse import Button, Controller import subprocess import time import AppKit +import pdb + mouse = Controller() #while True: def getDockSide(): + # pdb.set_trace() script = "defaults read com.apple.Dock orientation" result = subprocess.run(["bash", "-c", script], capture_output=True,text=True) - if result.stdout != None: - print(result.stdout) -dockSide = getDockSide() + return result.stdout def moveDock(to): script = f""" @@ -22,6 +23,7 @@ def moveDock(to): end tell """ result = subprocess.run(["osascript", "-e", script], capture_output=True, text=True) + return result.stdout # print(result.stdout) def getScreenSize(): @@ -35,7 +37,6 @@ def getScreenSize(): try: resultArr = [int(num) for num in result.stdout.strip().split(", ")] resultArr = resultArr[2:] - print("sdfioewiofj ", resultArr) return resultArr except ValueError: print("error parsing screensize") @@ -51,18 +52,68 @@ def getDockHeight(): visibleHeight = screen.visibleFrame().size.height dockHeight = fullHeight - visibleHeight - print(dockHeight) - percentage = (dockHeight / fullHeight) * 100 - return percentage - -moveDock("left") -time.sleep(0.1) -moveDock("bottom") -print("mousepos", mouse.position) + percentage = (dockHeight / fullHeight) + return percentage+0.03 # increase size screenSize = getScreenSize() -print(screenSize) + +print(getDockHeight()) +print(getScreenSize()) +moveDock("bottom") +dockSide = "bottom" +dockHeight = getDockHeight() + +print() +dockFromBottom = screenSize[1]-(screenSize[1]*dockHeight) +print(dockFromBottom) + +print() +dockFromLeft = screenSize[1]*dockHeight +print(dockFromLeft) + +print() +dockFromRight = screenSize[1]*dockHeight +dockFromRight = screenSize[0]-(screenSize[1]*dockHeight) +print(dockFromRight) + + + + + + while True: - if mouse.position[1] > 2600: - moveDock("left") - time.sleep(0.1) + # print(dockSide) + if dockSide == "bottom": + if mouse.position[1] > dockFromBottom: + if mouse.position[0] < screenSize[0]/2: + moveDock("right") + dockSide = "right" + #if mouse is at bottom and is on the left + else: + moveDock("left") + dockSide = "left" + #mouse is at bottom but on the right of screen + + elif dockSide == "left": + if mouse.position[0] < dockFromLeft: + if mouse.position[1] < screenSize[1]/2: + moveDock("bottom") + dockSide = "bottom" + #mouse is at left but top half + else: + moveDock("right") + dockSide = "right" + #mouse is at left but bottom half + + elif dockSide == "right": + if mouse.position[0] > dockFromRight: + if mouse.position[1] < screenSize[1]/2: + moveDock("bottom") + dockSide = "bottom" + #mouse is at right but top half + else: + moveDock("left") + dockSide = "left" + #mouse is at right but bottom half + + time.sleep(0.01)