Skip to content

Instantly share code, notes, and snippets.

@jerodsanto
Created September 20, 2011 15:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jerodsanto/1229361 to your computer and use it in GitHub Desktop.
Save jerodsanto/1229361 to your computer and use it in GitHub Desktop.
MacRuby script to set wallpaper on all connected monitors
#!/usr/bin/env macruby
abort "Usage: #{__FILE__} [image]" if ARGV.empty?
framework "Cocoa"
wallpaper_path = File.expand_path(ARGV.first)
wallpaper_url = NSURL.fileURLWithPath(wallpaper_path, isDirectory: false)
workspace = NSWorkspace.sharedWorkspace
NSScreen.screens.each do |screen|
workspace.setDesktopImageURL(wallpaper_url, forScreen:screen, options:nil, error:nil)
end
@jerodsanto
Copy link
Author

I can't find an easy way to loop this over all desktops in Mission Control. I toyed with sending keystrokes to trigger desktop switching, a la this app, but didn't get it working on first attempt.

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