Created
March 7, 2016 06:59
-
-
Save nvzqz/d6570461caa726b03d6f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env swift | |
import Foundation | |
let arguments = Process.arguments | |
guard arguments.count > 1 else { | |
fputs("Error: Location argument missing.\n", stderr) | |
exit(EXIT_FAILURE) | |
} | |
let location = arguments[1] | |
let defaults = NSUserDefaults.standardUserDefaults() | |
let domainName = "com.apple.screencapture" | |
var domain = defaults.persistentDomainForName(domainName) | |
as? [String : String] ?? [:] | |
domain["location"] = location | |
defaults.setPersistentDomain(domain, forName: domainName) | |
defaults.synchronize() | |
print("Success! Screenshot location has been updated to \"\(location)\".") | |
let task = NSTask() | |
task.launchPath = "/usr/bin/killall" | |
task.arguments = ["SystemUIServer"] | |
task.launch() | |
task.waitUntilExit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment