a lot faster now, it only moves the dock if the side its moving to is different

This commit is contained in:
neon443
2025-05-26 12:04:42 +01:00
parent c858fba082
commit 8a6840966f

View File

@@ -85,8 +85,9 @@ class MouseTracker {
} else { } else {
fatalError("no screen wtf???") fatalError("no screen wtf???")
} }
self.currentDockSide = .bottom self.currentDockSide = .left
moveDock(.bottom) moveDock(.bottom)
currentDockSide = .bottom
} }
func checkMouse(_ event: NSEvent) { func checkMouse(_ event: NSEvent) {
@@ -143,14 +144,27 @@ class MouseTracker {
} }
func moveDock(_ toSide: DockSide) { func moveDock(_ toSide: DockSide) {
let script = """ guard currentDockSide != toSide else { return }
// let scriptHide = """
// tell application "System Events"
// tell dock preferences
// set autohide to true
// end tell
// end tell
// """
//
// let scriptShow = scriptHide.replacingOccurrences(of: "true", with: "false")
let scriptMove = """
tell application "System Events" tell application "System Events"
tell dock preferences tell dock preferences
set screen edge to \(toSide) set screen edge to \(toSide)
end tell end tell
end tell end tell
""" """
applescript(script) // applescript(scriptHide)
applescript(scriptMove)
// applescript(scriptShow)
currentDockSide = toSide currentDockSide = toSide
} }