we can do most of the stuff in the python rewrite, screen size getting 
move dock 
get dock height
now just need to bring it together
This commit is contained in:
neon443
2025-03-15 15:20:36 +00:00
parent 90376a0857
commit 329f972afb
5 changed files with 104 additions and 32 deletions

View File

@@ -0,0 +1,20 @@
{
"actions" : {
"run" : {
"postActions" : [
{
"script" : ". *Py\/venv\/bin\/activate\npython3 *Py\/main.py",
"type" : "runScript"
}
]
}
},
"extension" : {
"identifier" : "net.danwatson.Python",
"name" : "Python"
},
"extensionTemplate" : "virtualenv",
"extensionValues" : {
"script" : "DockPhobiaPy\/main.py"
}
}

View File

@@ -29,16 +29,6 @@
path = DockPhobia;
sourceTree = "<group>";
};
A91E84B12D82CF4300FC2E5F /* DockPhobiaTests */ = {
isa = PBXFileSystemSynchronizedRootGroup;
path = DockPhobiaTests;
sourceTree = "<group>";
};
A91E84BB2D82CF4300FC2E5F /* DockPhobiaUITests */ = {
isa = PBXFileSystemSynchronizedRootGroup;
path = DockPhobiaUITests;
sourceTree = "<group>";
};
/* End PBXFileSystemSynchronizedRootGroup section */
/* Begin PBXFrameworksBuildPhase section */
@@ -56,8 +46,6 @@
isa = PBXGroup;
children = (
A91E849F2D82CF4100FC2E5F /* DockPhobia */,
A91E84B12D82CF4300FC2E5F /* DockPhobiaTests */,
A91E84BB2D82CF4300FC2E5F /* DockPhobiaUITests */,
A91E849E2D82CF4100FC2E5F /* Products */,
);
sourceTree = "<group>";

View File

@@ -89,9 +89,6 @@ struct DockPhobiaApp: App {
moveDock("right")
}
Divider()
Button("Move Dock to Right2") {
moveDockWithDefaults("right")
}
Button("Move Dock to Left") {
moveDock("left")
}
@@ -264,20 +261,3 @@ func moveDock(_ to: String) {
print("Error running AppleScript: \(error)")
}
}
func moveDockWithDefaults(_ to: String) {
let validPositions = ["left", "right", "bottom"]
guard validPositions.contains(to) else {
print("Invalid Dock position: \(to)")
return
}
let command = "defaults write com.apple.Dock orientation -string \(to);launchctl kickstart -k gui/$(id -u)/com.apple.Dock"
let result = shell(command)
if let error = result.error {
print("Error moving Dock: \(error)")
} else {
print("Dock moved to \(to)")
}
}

68
DockPhobiaPy/main.py Normal file
View File

@@ -0,0 +1,68 @@
from pynput.mouse import Button, Controller
import subprocess
import time
import AppKit
mouse = Controller()
#while True:
def getDockSide():
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()
def moveDock(to):
script = f"""
tell application "System Events"
tell dock preferences
set screen edge to {to}
end tell
end tell
"""
result = subprocess.run(["osascript", "-e", script], capture_output=True, text=True)
# print(result.stdout)
def getScreenSize():
script = """
tell application "Finder"
get bounds of window of desktop
end tell
"""
result = subprocess.run(["osascript", "-e", script], capture_output=True, text=True)
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")
return []
screenSize = getScreenSize()
print(f"Screen size: {screenSize}")
def getDockHeight():
screen = AppKit.NSScreen.mainScreen()
fullHeight = screen.frame().size.height
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)
screenSize = getScreenSize()
print(screenSize)
while True:
if mouse.position[1] > 2600:
moveDock("left")
time.sleep(0.1)

View File

@@ -0,0 +1,16 @@
MouseInfo==0.1.3
PyAutoGUI==0.9.54
PyGetWindow==0.0.9
PyMsgBox==1.0.9
pynput==1.8.0
pyobjc-core==11.0
pyobjc-framework-ApplicationServices==11.0
pyobjc-framework-Cocoa==11.0
pyobjc-framework-CoreText==11.0
pyobjc-framework-Quartz==11.0
pyperclip==1.9.0
PyRect==0.2.0
PyScreeze==1.0.1
pytweening==1.2.0
rubicon-objc==0.5.0
six==1.17.0