first commit

This commit is contained in:
Chad Nelson 2025-03-08 13:36:53 -07:00
parent a098b17f71
commit ede81a0a6d
14 changed files with 184 additions and 3 deletions

View file

@ -1,51 +1,61 @@
{
"images" : [
{
"filename" : "gigakamiguru -v.1.2 CMYK16x16.eps.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"filename" : "gigakamiguru -v.1.2 CMYK32x32.eps.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"filename" : "gigakamiguru -v.1.2 CMYK32x32.eps 1.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"filename" : "gigakamiguru -v.1.2 CMYK64x64.eps.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"filename" : "gigakamiguru -v.1.2 CMY128x128.eps.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"filename" : "gigakamiguru -v.1.2 CMY256x256.eps.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"filename" : "gigakamiguru -v.1.2 CMY256x256.eps 1.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"filename" : "gigakamiguru -v.1.2 CMY512x512.eps.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"filename" : "gigakamiguru -v.1.2 CMY512x512.eps 1.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"filename" : "gigakamiguru -v.1.2 CMY1024x1024.eps.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 969 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

View file

@ -8,14 +8,95 @@
import SwiftUI
struct ContentView: View {
@State public var output: String = "Please select an option \n"
private let maxLines = 300
@State private var showCancelButton: Bool = false
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
ScrollViewReader { proxy in
ScrollView {
VStack(alignment: .leading) {
TextEditor(text: $output)
.font(.system(.body, design: .monospaced))
.frame(minWidth: 750, minHeight: 300)
.padding()
.disabled(true)
Text("")
.id("bottom")
}
}
.onChange(of: output) { _, _ in
trimLinesIfNeeded()
withAnimation {
proxy.scrollTo("bottom", anchor: .bottom)
}
}
}
HStack {
Button(action: {
DispatchQueue.main.async {
self.showCancelButton = true
}
runShellCommandAsync(command: "msg machine init", outputText: $output, showButton: $showCancelButton)
}) {
Text("Init")
}
Button(action: {
DispatchQueue.main.async {
self.showCancelButton = true
}
runShellCommandAsync(command: "rm -rf ~/.guix && msg machine init", outputText: $output, showButton: nil) }) {
Text("Reinit")
}
Button(action: {
runShellCommandAsync(command: "msg machine start", outputText: $output, showButton: nil) }) {
Text("Start")
}
if showCancelButton {
Button(action: {
runShellCommandAsync(command: "kill $(ps aux | grep '[g]uile' | awk '{print $2}')", outputText: $output, showButton: nil)
runShellCommandAsync(command: "kill $(ps aux | grep '[q]emu' | awk '{print $2}')", outputText: $output, showButton: nil)
DispatchQueue.main.async {
self.showCancelButton = false
}}) {
Text("Cancel")
}
}
if !showCancelButton{
Button(action: {
runShellCommandAsync(command: "msg machine stop", outputText: $output, showButton: nil) }) {
Text("Stop")
}
}
Button(action: {
runShellCommandAsync(command: "osascript -e 'tell application \"Terminal\" to do script \"msg shell\"' -e 'tell application \"Terminal\" to activate'", outputText: $output, showButton: nil)
}) {
Text("Shell")
}
}
}
.padding()
.frame(width: 800, height: 400)
}
private func trimLinesIfNeeded() {
let lines = output.split(separator: "\n")
if lines.count > maxLines {
_ = lines.count - maxLines
let trimmedLines = lines.suffix(maxLines) // Keep only the last 300 lines
output = trimmedLines.joined(separator: "\n") // Join back to a single string
}
}
}

View file

@ -3,8 +3,8 @@
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<false/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<false/>
</dict>
</plist>

View file

@ -6,6 +6,96 @@
//
import SwiftUI
import Foundation
func oldshell(_ command: String) -> String {
let task = Process()
let pipe = Pipe()
task.standardOutput = pipe
task.standardError = pipe
task.arguments = ["-c", command]
task.launchPath = "/bin/zsh"
task.standardInput = nil
task.launch()
let data = pipe.fileHandleForReading.readDataToEndOfFile()
let output = String(data: data, encoding: .utf8)!
return output
}
func runShellCommandAsync(command: String, outputText: Binding<String>, showButton: Binding<Bool>?) {
DispatchQueue.global(qos: .background).async {
let task = Process()
let pipe = Pipe()
task.standardOutput = pipe
task.standardError = pipe
task.arguments = ["-c", command]
task.launchPath = "/bin/zsh"
task.standardInput = nil
task.environment = [
"GUILE_LOAD_PATH": "/opt/homebrew/share/guile/site/3.0:/usr/local/share/guile/site/3.0/",
"GUILE_LOAD_COMPILED_PATH": "/opt/homebrew/lib/guile/3.0/site-ccache:/usr/local/lib/guile/3.0/site-ccache/",
"GUILE_SYSTEM_EXTENSIONS_PATH": "/opt/homebrew/lib/guile/3.0/extensions:/usr/local/lib/guile/3.0/extensions/",
"PATH": "$PATH:/opt/homebrew/bin:/usr/bin:/usr/local/bin:/bin"
]
task.launch()
let fileHandle = pipe.fileHandleForReading
fileHandle.waitForDataInBackgroundAndNotify()
var observer: NSObjectProtocol?
observer = NotificationCenter.default.addObserver(forName: .NSFileHandleDataAvailable, object: fileHandle, queue: nil) { _ in
let data = fileHandle.availableData
if let output = String(data: data, encoding: .utf8), !output.isEmpty {
DispatchQueue.main.async {
outputText.wrappedValue += output
}
}
fileHandle.waitForDataInBackgroundAndNotify()
}
task.waitUntilExit()
if let observer = observer {
NotificationCenter.default.removeObserver(observer)
}
if showButton != nil {
showButton?.wrappedValue = false;
}
}
}
func shell(_ command: String) -> String {
let task = Process()
let pipe = Pipe()
task.standardOutput = pipe
task.standardError = pipe
task.arguments = ["-c", command]
task.launchPath = "/bin/zsh"
task.standardInput = nil
task.environment = [
"GUILE_LOAD_PATH": "/opt/homebrew/share/guile/site/3.0:/usr/local/share/guile/site/3.0/",
"GUILE_LOAD_COMPILED_PATH": "/opt/homebrew/lib/guile/3.0/site-ccache:/usr/local/lib/guile/3.0/site-ccache/",
"GUILE_SYSTEM_EXTENSIONS_PATH": "/opt/homebrew/lib/guile/3.0/extensions:/usr/local/lib/guile/3.0/extensions/",
"PATH": "$PATH:/opt/homebrew/bin:/usr/bin:/usr/local/bin:/bin"
]
task.launch()
let data = pipe.fileHandleForReading.readDataToEndOfFile()
let output = String(data: data, encoding: .utf8) ?? "Error reading output"
return output.trimmingCharacters(in: .whitespacesAndNewlines)
}
@main
struct MSG_DesktopApp: App {