Skip to content

Instantly share code, notes, and snippets.

@greenywd
Created March 14, 2017 23:33
Show Gist options
  • Save greenywd/d7fdc3d3933fc42f3aaa2d4fccca3944 to your computer and use it in GitHub Desktop.
Save greenywd/d7fdc3d3933fc42f3aaa2d4fccca3944 to your computer and use it in GitHub Desktop.
//: Playground - noun: a place where people can play
import Cocoa
//path to image
let image = "/Library/Desktop Pictures/Sierra.jpg"
let url = NSURL.fileURL(withPath: image)
let workspace = NSWorkspace.shared()
let screen = NSScreen.main()
let dic: [String : Any] = ["NSWorkspaceDesktopImageScalingKey" : 1]
var result: () = try workspace.setDesktopImageURL(url, for: screen!, options: dic)
@greenywd
Copy link
Author

Swift Playground code to change the wallpaper using Swift 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment