更改桌面背景mac os x

时间:2013-11-25 20:54:08

标签: java macos javafx-2

请告诉我如何以编程方式更改Mac OS X中的桌面背景? 我找到了,但对于Windows https://stackoverflow.com/a/12212368/2838676

1 个答案:

答案 0 :(得分: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);
}

积分

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