mirror of
https://github.com/neon443/DockPhobia.git
synced 2026-03-11 06:49:12 +00:00
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
This commit is contained in:
20
.nova/Tasks/Virtual Environment.json
Normal file
20
.nova/Tasks/Virtual Environment.json
Normal 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"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,16 +29,6 @@
|
|||||||
path = DockPhobia;
|
path = DockPhobia;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
A91E84B12D82CF4300FC2E5F /* DockPhobiaTests */ = {
|
|
||||||
isa = PBXFileSystemSynchronizedRootGroup;
|
|
||||||
path = DockPhobiaTests;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
A91E84BB2D82CF4300FC2E5F /* DockPhobiaUITests */ = {
|
|
||||||
isa = PBXFileSystemSynchronizedRootGroup;
|
|
||||||
path = DockPhobiaUITests;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
/* End PBXFileSystemSynchronizedRootGroup section */
|
/* End PBXFileSystemSynchronizedRootGroup section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@@ -56,8 +46,6 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
A91E849F2D82CF4100FC2E5F /* DockPhobia */,
|
A91E849F2D82CF4100FC2E5F /* DockPhobia */,
|
||||||
A91E84B12D82CF4300FC2E5F /* DockPhobiaTests */,
|
|
||||||
A91E84BB2D82CF4300FC2E5F /* DockPhobiaUITests */,
|
|
||||||
A91E849E2D82CF4100FC2E5F /* Products */,
|
A91E849E2D82CF4100FC2E5F /* Products */,
|
||||||
);
|
);
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
|||||||
@@ -89,9 +89,6 @@ struct DockPhobiaApp: App {
|
|||||||
moveDock("right")
|
moveDock("right")
|
||||||
}
|
}
|
||||||
Divider()
|
Divider()
|
||||||
Button("Move Dock to Right2") {
|
|
||||||
moveDockWithDefaults("right")
|
|
||||||
}
|
|
||||||
Button("Move Dock to Left") {
|
Button("Move Dock to Left") {
|
||||||
moveDock("left")
|
moveDock("left")
|
||||||
}
|
}
|
||||||
@@ -264,20 +261,3 @@ func moveDock(_ to: String) {
|
|||||||
print("Error running AppleScript: \(error)")
|
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
68
DockPhobiaPy/main.py
Normal 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)
|
||||||
16
DockPhobiaPy/requirements.txt
Normal file
16
DockPhobiaPy/requirements.txt
Normal 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
|
||||||
Reference in New Issue
Block a user