rewrote getScreenSize() -> (x: Int, y: Int)

This commit is contained in:
neon443
2025-03-18 21:19:11 +00:00
parent a134920dda
commit 96eec065b8
2 changed files with 69 additions and 17 deletions

View File

@@ -14,8 +14,8 @@
filePath = "DockPhobia/DockPhobiaApp.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "178"
endingLineNumber = "178"
startingLineNumber = "181"
endingLineNumber = "181"
landmarkName = "getDockSide()"
landmarkType = "9">
</BreakpointContent>
@@ -30,9 +30,57 @@
filePath = "DockPhobia/DockPhobiaApp.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "262"
endingLineNumber = "262"
landmarkName = "moveDock(_:)"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "F8A3FA77-893B-450F-AD59-E5BC7DCE49E3"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "DockPhobia/DockPhobiaApp.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "173"
endingLineNumber = "173"
landmarkName = "osascript(_:)"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "BD0ABCBD-CF09-4CA6-96F0-684CED97F209"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "DockPhobia/DockPhobiaApp.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "252"
endingLineNumber = "252"
landmarkName = "getScreenSize()"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "24C8E220-523C-4656-897A-B41ABA405D6B"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "DockPhobia/DockPhobiaApp.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "258"
endingLineNumber = "258"
landmarkName = "moveDock(_:)"
landmarkName = "getScreenSize()"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>

View File

@@ -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) {