0

please tell me how to programmatically change the desktop background in Mac OS X? I found, but for windows https://stackoverflow.com/a/12212368/2838676

Community
  • 1
  • 1
mr_nobody
  • 194
  • 3
  • 17
  • 1
    Have a look at [this](http://stackoverflow.com/questions/19779980/is-it-possible-to-change-the-desktop-background-with-java-for-different-operatin) or [this](http://stackoverflow.com/questions/6199907/change-desktop-background-of-mac-sytem-using-java-native-access) – James Barnett Nov 25 '13 at 21:08

1 Answers1

1
public void setWallpaper(File file)
throws Exception {
    String as[] = {
            "osascript", 
            "-e", "tell application \"Finder\"", 
            "-e", "set desktop picture to POSIX file \"" + file.getAbsolutePath() + "\"",
            "-e", "end tell"
    };
    Runtime runtime = Runtime.getRuntime();
    Process process;
    process = runtime.exec(as);
}

Credits

https://stackoverflow.com/a/5007344/1401250

https://sourceforge.net/p/jawc-wallpaperc/code/HEAD/tree/trunk/Jawc/src/it/jwallpaper/platform/impl/MacPlatform.java#l38

Community
  • 1
  • 1
user1401250
  • 336
  • 2
  • 7