Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Miles.Kelly97

macrumors member
Original poster
Nov 24, 2015
34
0
Tunbridge Wells
Hi guys,

I was wondering if I could have a bit of help with this. I am trying to create a Status bar app that will run a Shell script when a button is pressed but I am not sure how to do this.

The command is "defaults write com.apple.finder CreateDesktop -bool FALSE;killall Finder" It hides the desktop.

Could anyone give me any advance as to how to get a button pressed to action that command?

Thanks Miles
 
Hi guys,

I was wondering if I could have a bit of help with this. I am trying to create a Status bar app that will run a Shell script when a button is pressed but I am not sure how to do this.

The command is "defaults write com.apple.finder CreateDesktop -bool FALSE;killall Finder" It hides the desktop.

Could anyone give me any advance as to how to get a button pressed to action that command?

Thanks Miles

Something like this (found this on StackOverflow)

Code:
import Foundation

@discardableResult
func shell(_ args: String...) -> Int32 {
    let task = Process()
    task.launchPath = "/usr/bin/env"
    task.arguments = args
    task.launch()
    task.waitUntilExit()
    return task.terminationStatus
}

shell("ls")
shell("xcodebuild", "-workspace", "myApp.xcworkspace")

Note - I haven't tried anything like this. Just what I found online.

https://stackoverflow.com/questions...inal-command-in-a-swift-script-e-g-xcodebuild
 
  • Like
Reactions: Miles.Kelly97
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.