From 329f972afb2f3ba62a329ea66662594beef1dbb8 Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Sat, 15 Mar 2025 15:20:36 +0000 Subject: [PATCH] yessssss 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 --- .nova/Tasks/Virtual Environment.json | 20 ++++++++ DockPhobia.xcodeproj/project.pbxproj | 12 ----- DockPhobia/DockPhobiaApp.swift | 20 -------- DockPhobiaPy/main.py | 68 ++++++++++++++++++++++++++++ DockPhobiaPy/requirements.txt | 16 +++++++ 5 files changed, 104 insertions(+), 32 deletions(-) create mode 100644 .nova/Tasks/Virtual Environment.json create mode 100644 DockPhobiaPy/main.py create mode 100644 DockPhobiaPy/requirements.txt diff --git a/.nova/Tasks/Virtual Environment.json b/.nova/Tasks/Virtual Environment.json new file mode 100644 index 0000000..c3d78f8 --- /dev/null +++ b/.nova/Tasks/Virtual Environment.json @@ -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" + } +} diff --git a/DockPhobia.xcodeproj/project.pbxproj b/DockPhobia.xcodeproj/project.pbxproj index b0bf234..fc01060 100644 --- a/DockPhobia.xcodeproj/project.pbxproj +++ b/DockPhobia.xcodeproj/project.pbxproj @@ -29,16 +29,6 @@ path = DockPhobia; sourceTree = ""; }; - A91E84B12D82CF4300FC2E5F /* DockPhobiaTests */ = { - isa = PBXFileSystemSynchronizedRootGroup; - path = DockPhobiaTests; - sourceTree = ""; - }; - A91E84BB2D82CF4300FC2E5F /* DockPhobiaUITests */ = { - isa = PBXFileSystemSynchronizedRootGroup; - path = DockPhobiaUITests; - sourceTree = ""; - }; /* End PBXFileSystemSynchronizedRootGroup section */ /* Begin PBXFrameworksBuildPhase section */ @@ -56,8 +46,6 @@ isa = PBXGroup; children = ( A91E849F2D82CF4100FC2E5F /* DockPhobia */, - A91E84B12D82CF4300FC2E5F /* DockPhobiaTests */, - A91E84BB2D82CF4300FC2E5F /* DockPhobiaUITests */, A91E849E2D82CF4100FC2E5F /* Products */, ); sourceTree = ""; diff --git a/DockPhobia/DockPhobiaApp.swift b/DockPhobia/DockPhobiaApp.swift index 2eb4593..bc2e29c 100644 --- a/DockPhobia/DockPhobiaApp.swift +++ b/DockPhobia/DockPhobiaApp.swift @@ -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)") - } -} diff --git a/DockPhobiaPy/main.py b/DockPhobiaPy/main.py new file mode 100644 index 0000000..19b3d3e --- /dev/null +++ b/DockPhobiaPy/main.py @@ -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) diff --git a/DockPhobiaPy/requirements.txt b/DockPhobiaPy/requirements.txt new file mode 100644 index 0000000..c9b7d36 --- /dev/null +++ b/DockPhobiaPy/requirements.txt @@ -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