mirror of
https://github.com/neon443/DockPhobia.git
synced 2026-03-11 06:49:12 +00:00
rewrote the shell function, not many changes made
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Bucket
|
||||
uuid = "5129BCB4-F937-4489-8C1C-31D2F9C7AB6F"
|
||||
type = "0"
|
||||
version = "2.0">
|
||||
<Breakpoints>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "43FA2B17-A22F-4470-ABDF-93C565F4F12F"
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "DockPhobia/DockPhobiaApp.swift"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "139"
|
||||
endingLineNumber = "139"
|
||||
landmarkName = "shell(_:)"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
</Breakpoints>
|
||||
</Bucket>
|
||||
@@ -82,7 +82,7 @@ struct DockPhobiaApp: App {
|
||||
.keyboardShortcut(",")
|
||||
Divider()
|
||||
Button("try shell") {
|
||||
print(shell("echo hello") ?? "fuck me")
|
||||
print(shell("echo hello"))
|
||||
}
|
||||
Divider()
|
||||
Button("Move Dock to Right") {
|
||||
@@ -114,24 +114,29 @@ func shell(_ command: String) -> (output: String?, error: String?) {
|
||||
let pipe = Pipe()
|
||||
let pipeError = Pipe()
|
||||
|
||||
process.executableURL = URL(fileURLWithPath: "/bin/bash")
|
||||
process.executableURL = URL(fileURLWithPath: "/bin/zsh")
|
||||
process.arguments = ["-c", command]
|
||||
process.standardOutput = pipe
|
||||
process.standardError = pipeError
|
||||
|
||||
let outputHandle = pipe.fileHandleForReading
|
||||
let errorHandle = pipeError.fileHandleForReading
|
||||
let outputErrorHandle = pipeError.fileHandleForReading
|
||||
|
||||
process.launch()
|
||||
process.waitUntilExit()
|
||||
|
||||
let data = outputHandle.readDataToEndOfFile()
|
||||
let dataError = errorHandle.readDataToEndOfFile()
|
||||
let dataError = outputErrorHandle.readDataToEndOfFile()
|
||||
|
||||
let output = String(data: data, encoding: .utf8)?.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
let outputError = String(data: dataError, encoding: .utf8)?.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
|
||||
return (output, outputError)
|
||||
let output = String(
|
||||
data: data,
|
||||
encoding: .utf8
|
||||
)?.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
let outputError = String(
|
||||
data: dataError,
|
||||
encoding: .utf8
|
||||
)?.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
return (output: output, error: outputError)
|
||||
}
|
||||
|
||||
func getDockSide() -> String {
|
||||
|
||||
Reference in New Issue
Block a user