first commit
|
@ -1,51 +1,61 @@
|
||||||
{
|
{
|
||||||
"images" : [
|
"images" : [
|
||||||
{
|
{
|
||||||
|
"filename" : "gigakamiguru -v.1.2 CMYK16x16.eps.png",
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "1x",
|
"scale" : "1x",
|
||||||
"size" : "16x16"
|
"size" : "16x16"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"filename" : "gigakamiguru -v.1.2 CMYK32x32.eps.png",
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "2x",
|
"scale" : "2x",
|
||||||
"size" : "16x16"
|
"size" : "16x16"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"filename" : "gigakamiguru -v.1.2 CMYK32x32.eps 1.png",
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "1x",
|
"scale" : "1x",
|
||||||
"size" : "32x32"
|
"size" : "32x32"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"filename" : "gigakamiguru -v.1.2 CMYK64x64.eps.png",
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "2x",
|
"scale" : "2x",
|
||||||
"size" : "32x32"
|
"size" : "32x32"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"filename" : "gigakamiguru -v.1.2 CMY128x128.eps.png",
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "1x",
|
"scale" : "1x",
|
||||||
"size" : "128x128"
|
"size" : "128x128"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"filename" : "gigakamiguru -v.1.2 CMY256x256.eps.png",
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "2x",
|
"scale" : "2x",
|
||||||
"size" : "128x128"
|
"size" : "128x128"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"filename" : "gigakamiguru -v.1.2 CMY256x256.eps 1.png",
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "1x",
|
"scale" : "1x",
|
||||||
"size" : "256x256"
|
"size" : "256x256"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"filename" : "gigakamiguru -v.1.2 CMY512x512.eps.png",
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "2x",
|
"scale" : "2x",
|
||||||
"size" : "256x256"
|
"size" : "256x256"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"filename" : "gigakamiguru -v.1.2 CMY512x512.eps 1.png",
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "1x",
|
"scale" : "1x",
|
||||||
"size" : "512x512"
|
"size" : "512x512"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"filename" : "gigakamiguru -v.1.2 CMY1024x1024.eps.png",
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "2x",
|
"scale" : "2x",
|
||||||
"size" : "512x512"
|
"size" : "512x512"
|
||||||
|
|
After Width: | Height: | Size: 169 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 77 KiB |
After Width: | Height: | Size: 77 KiB |
After Width: | Height: | Size: 969 B |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 7 KiB |
|
@ -8,15 +8,96 @@
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct ContentView: View {
|
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 {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
Image(systemName: "globe")
|
Image(systemName: "globe")
|
||||||
.imageScale(.large)
|
.imageScale(.large)
|
||||||
.foregroundStyle(.tint)
|
.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()
|
.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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#Preview {
|
#Preview {
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>com.apple.security.app-sandbox</key>
|
<key>com.apple.security.app-sandbox</key>
|
||||||
<true/>
|
<false/>
|
||||||
<key>com.apple.security.files.user-selected.read-only</key>
|
<key>com.apple.security.files.user-selected.read-only</key>
|
||||||
<true/>
|
<false/>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|
|
@ -6,6 +6,96 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
import SwiftUI
|
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
|
@main
|
||||||
struct MSG_DesktopApp: App {
|
struct MSG_DesktopApp: App {
|
||||||
|
|