diff --git a/DockPhobia.xcworkspace/xcuserdata/neon443.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/DockPhobia.xcworkspace/xcuserdata/neon443.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 8b5c80f..414acfd 100644 --- a/DockPhobia.xcworkspace/xcuserdata/neon443.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/DockPhobia.xcworkspace/xcuserdata/neon443.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -14,8 +14,8 @@ filePath = "DockPhobia/DockPhobiaApp.swift" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "178" - endingLineNumber = "178" + startingLineNumber = "181" + endingLineNumber = "181" landmarkName = "getDockSide()" landmarkType = "9"> @@ -30,9 +30,57 @@ filePath = "DockPhobia/DockPhobiaApp.swift" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" + startingLineNumber = "262" + endingLineNumber = "262" + landmarkName = "moveDock(_:)" + landmarkType = "9"> + + + + + + + + + + + + diff --git a/DockPhobia/DockPhobiaApp.swift b/DockPhobia/DockPhobiaApp.swift index 6d5f010..6b9d63d 100644 --- a/DockPhobia/DockPhobiaApp.swift +++ b/DockPhobia/DockPhobiaApp.swift @@ -139,7 +139,7 @@ func shell(_ command: String) -> (output: String?, error: String?) { return (output: output, error: outputError) } -func osascript(_ script: String) -> (output: String?, error: String?) { +func osascript(_ script: String) -> String? { let process = Process() let outputPipe = Pipe() let outputErrorPipe = Pipe() @@ -169,7 +169,10 @@ func osascript(_ script: String) -> (output: String?, error: String?) { .trimmingCharacters( in: .whitespacesAndNewlines ) - return (outputData, outputErrorData) + if outputErrorData != "" { + print(outputErrorData as Any) + } + return outputData } func getDockSide() -> String { @@ -240,18 +243,19 @@ func stopTrackingMouse() { } } -func getScreenSize() -> (x: CGFloat, y: CGFloat) { - if let screen = NSScreen.main { - let screenFrame = screen.frame - let maxWidth = screenFrame.width - let maxHeight = screenFrame.height -// print("screen res: \(maxWidth)x\(maxHeight)") - return (maxWidth, maxHeight) - } else { - print("you have no screen") - print("what the fuck") - return (-1.0, -1.0) //help me... i am not accounting for edge cases like this shit - } +func getScreenSize() -> (x: Int, y: Int) { + let script = """ + tell application "Finder" + get bounds of window of desktop + end tell + """ + let result = osascript(script)?.dropFirst(6).split(separator: ", ") + // removes the "0, 0, " and splits into an arr + let resultTuple = ( + Int( result![0] )!, + Int( result![1] )! + ) + return resultTuple } func moveDock(_ to: String) {