I can’t seem to find an API reference for the LL current desktop wallpaper.
I can’t seem to find an API reference for the LL current desktop wallpaper. How would I access a desktop specific wallpaper in order to change it in a script? Thanks.
]]>
< ![CDATA[
Sub
]]>
< ![CDATA[
Unfortunately there is no public API for this yet, but you can use a hack: replace (or delete) the file in the app data directory named pages/container_id/wp (replace container_id with the value returned by Container.getId()), then restart the launcher with LL.runAction(EventHandler.RESTART);
]]>
< ![CDATA[
Thanks! It makes me feel better that I didn’t just miss the reference. Hacks are perfectly acceptable for my purposes. 🙂
]]>
< ![CDATA[
I can’t seem to find the app’s data directory you’re referring to. Android/data/net.pierrox.lightning_launcher/files is empty and there’s nothing like you mention in LightningLauncher/tmp. Thanks.
]]>
< ![CDATA[
This is the app data directory in /data/data/the_app_package_name/files.
You can retrieve this directory using LL.getContext().getFilesDir().
]]>
< ![CDATA[
In case this was interesting to anyone, here’s a wallpaper changer script assuming your wallpapers are in a specific directory. It doesn’t handle errors or anything, but it might help anyone trying to do something similar.
LL.bindClass(“java.lang.Runtime”);
LL.bindClass(“java.io.File”);
var wallpaper_dir = new File(“/storage…”) //replace with wallpaper directory
var container_id = LL.getCurrentDesktop().getId() ;
var ll_wallpaper = new File(LL.getContext().getFilesDir() + “/pages/” + container_id + “/wp”);
ll_wallpaper.delete();
var wallpaper_list = wallpaper_dir.listFiles()
var index = Math.floor((Math.random() * wallpaper_list.length));
var rt = Runtime.getRuntime()
rt.exec(“cp ” + wallpaper_list[index].getAbsolutePath() + ” ” + ll_wallpaper.getAbsolutePath());
LL.runAction(EventHandler.RESTART);
]]>