A little bit update for official scripts [script_change_homescreen]
thanks for Lukas Morawietz’s answer in my this question https://plus.google.com/105062416156990739160/posts/3hqSu7pfMXJ
I add this part ‘ // write the current file’
it functions this:
– when press home button with preivous script, the target desktop maybe not the desktop I wanna
– modifiy current (variable in files) can make the home desktop be same with the current desktop.
The reason for this question:
– I definite the var for setHomeDesktop mannully
– I run this script outside of the LL
Tips:
If set the desktop mannually, we need root to view the config files to get the desktop ids in our mind.
———————–
//import java classes
LL.bindClass(“java.io.FileReader”);
LL.bindClass(“java.io.BufferedReader”);
LL.bindClass(“java.io.FileWriter”);
LL.bindClass(“java.io.File”);
LL.bindClass(“java.lang.System”);
//set Desktop with Id as Homescreen
setHomeDesktop=function(id)
{
//create the needed structure
var file=new File(“data/data/net.pierrox.lightning_launcher_extreme/files/config”);//this file contains desktop properties
var r=new BufferedReader(new FileReader(file));
var s=””;
//read the file
var l=r.readLine();
while(l!=null)
{
s+=l;
l=r.readLine();
}
//change the property
var data=JSON.parse(s);
data.homeScreen=id;
//write the changed stuff back to the file
var w=new FileWriter(file);
w.write(JSON.stringify(data));
w.flush();
w.close();
// write the current file
var file_cur=new File(“data/data/net.pierrox.lightning_launcher_extreme/files/current”);//this file contains desktop properties
var r_cur=new BufferedReader(new FileReader(file));
var w_cur=new FileWriter(file_cur);
w_cur.write(id);
w_cur.flush();
w_cur.close();
//restart the launcher
System.runFinalization();
System.exit(0);
}
setHomeDesktop(LL.getEvent().getData());