mirror of
https://github.com/neon443/DockPhobia.git
synced 2026-03-11 06:49:12 +00:00
DONE!!!!!!!!!!!!!
now the values are fetched programmatically!! btw if ur screen size changes, or ur dock size changes, restart the program not dynamically updating yet
This commit is contained in:
@@ -6,7 +6,8 @@
|
||||
<string>allow it</string>
|
||||
<key>NSAccessibilitysUsageDescription</key>
|
||||
<string>allow it</string>
|
||||
<com.apple.security.automation.apple-events>
|
||||
<key>com.apple.security.automation.apple-events<>
|
||||
<true>
|
||||
<key>com.apple.security.scripting-targets</key>
|
||||
<dict>
|
||||
<key>com.apple.mail</key>
|
||||
|
||||
@@ -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:
|
||||
# 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")
|
||||
time.sleep(0.1)
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user