From 8a6840966fb38ad10e0b49429b365cc33b43a830 Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Mon, 26 May 2025 12:04:42 +0100 Subject: [PATCH] a lot faster now, it only moves the dock if the side its moving to is different --- DockPhobia/MouseTracker.swift | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/DockPhobia/MouseTracker.swift b/DockPhobia/MouseTracker.swift index 8b49683..e469d85 100644 --- a/DockPhobia/MouseTracker.swift +++ b/DockPhobia/MouseTracker.swift @@ -85,8 +85,9 @@ class MouseTracker { } else { fatalError("no screen wtf???") } - self.currentDockSide = .bottom + self.currentDockSide = .left moveDock(.bottom) + currentDockSide = .bottom } func checkMouse(_ event: NSEvent) { @@ -143,14 +144,27 @@ class MouseTracker { } 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 dock preferences set screen edge to \(toSide) end tell end tell """ - applescript(script) +// applescript(scriptHide) + applescript(scriptMove) +// applescript(scriptShow) currentDockSide = toSide }