now browsing by category
Hello, I’m not good in scripting but i try and learn every day.
(sorry for my english, hope you will understand :-))
Also a big Thanks to the community.
Now here is a script. Maybe someone find it useful.
I have one desktop with an analog clock widget. I use WallpaperChanger and if i change the background the kontrast of th clock widget is low. I want to move the widget to another position by “longtap” the desktop.
The touch position will be calculated by the script and send to the “setPosition” of the object. The half of the objects hight and width must substracted to get the object center. In my case i add this manually because i don’t know ho to do this in a script.
After longtap on the desktop the clock moves to the tap position.
I know i could open the edit mode and move the widget, but for me is this script an more elegant solution.
Here is the script
(tipps for optimization are welcome)
var e = LL.getEvent();
var ey = e.getTouchY();
var ex = e.getTouchX();
LL.getCurrentDesktop().
getItemByName(‘clock’).
setPosition(ex -116, ey -108);
LL.getCurrentDesktop().
getItemByName(‘clock’).
setVisibility(true);
]]>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());
If possible, can anyone help me with sample scripts to show and hide panels? I’ve searched and cannot seem to find…
Thanks in advance!
]]>Playing around with Jappie Toutenhoofd ‘s scripts and trying to disintermediate Tasker with LL scripts …
Has anyone successfully used a LL script to pull a geolocation (lat, lon) from Android’s location manager?
]]>Hi all, this is a question for the more experienced script programmers.
After some searching I found this: http://stackoverflow.com/questions/1646698/what-is-the-new-keyword-in-javascript
I implemented this in a small example script:
dummy = LL.getCurrentDesktop().addShortcut(“dummy”,new Intent(),0,0);
// OLD WAY
/*
function displayCenter(it, center){
it.setLabel(center[0]+”,”+center[1]);
}
function moveToCenter(it, center){
it.setPosition(center[0], center[1]);
}
function center(item){
var r=item.getRotation()*Math.PI/180;
var sin=Math.abs(Math.sin(r));
var cos=Math.abs(Math.cos(r));
var w=item.getWidth()*item.getScaleX();
var h=item.getHeight()*item.getScaleY();
return[item.getPositionX()+(w*cos+h*sin)*0.5,item.getPositionY()+(h*cos+w*sin)*0.5];
}
var center = center(dummy);
displayCenter(dummy, center);
moveToCenter(dummy, center);
*/
//NEW WAY:
myItem = function(){
this.getCenter = function(){
if(this.center==null){
alert(“test”)
var r=this.getRotation()*Math.PI/180;
var sin=Math.abs(Math.sin(r));
var cos=Math.abs(Math.cos(r));
var w=this.getWidth()*this.getScaleX();
var h=this.getHeight()*this.getScaleY();
var center = [this.getPositionX()+(w*cos+h*sin)*0.5,this.getPositionY()+(h*cos+w*sin)*0.5]
this.center = center;
}
return this.center;
};
this.displayCenter = function(){
this.setLabel(this.getCenter()[0]+”, “+this.getCenter()[1]);
};
this.moveToCenter = function(){
this.setPosition(this.getCenter()[0], this.getCenter()[1]);
};
};
myItem.prototype = dummy;
myDummy = new myItem();
myDummy.displayCenter();
myDummy.moveToCenter();
myDummy.setSize(288, myDummy.getHeight()) //ALSO STILL WORKS BOTH WORK ON SAME OBJECT DESPITE THAT I DIDN’T DEFINE A getPositionX() IN myItem
As you can see this enables me to do what I explained herebove, but I haven’t seen anyone do it before, so I am wondering if there is anything bad happening here or I actually found something cool and useful.
Please tell me what you think in the comments.
Thanks for reading
cdfa
Hi all, this is a question for the more experienced users: I was looking at ways to optimize my code and I found…
I implemented this in a small example script:
dummy = LL.getCurrentDesktop().addShortcut(“dummy”,new Intent(),0,0);
myItem = function(){
this.getCenter = function(){
var r=this.getRotation()*Math.PI/180;
var sin=Math.abs(Math.sin(r));
var cos=Math.abs(Math.cos(r));
var w=this.getWidth()*this.getScaleX();
var h=this.getHeight()*this.getScaleY();
return[this.getPositionX()+(w*cos+h*sin)*0.5,this.getPositionY()+(h*cos+w*sin)*0.5];
};
};
myItem.prototype = dummy;
myDummy = new myItem();
alert(myDummy.getCenter()[0])
alert(myDummy.getPositionX()) // BOTH WORK ON SAME OBJECT AND DIDN’T DEFINE A getPositionX() IN myItem
I never seen anyone use this, so I was wondering if there is anything that makes this very inefficient or I actually discovered something pretty cool.
Thanks for reading
Colin
This is a universal copy&paste binding to easy set up.

This is a universal copy&paste binding to easy set up.
It allows you to make easily (basic binding knowledge required, this is a help tool) a binding outputting a number between two values based on a 0/1 variable.
Use this with the easy toggle
1-$variable
Features:
Easy to set variable to use
Custom initial/final values
Custom duration of all animation steps (offset, duration…)
Custom animation type
Optional autoback feature (will automatically play back on each change, like a spring)
]]>How can one pass script data from a Lightning action “run a script” to be used in the script?
Tried LL.getEvent().getData() but the script data was not passed even though dialog was checked in “run a script” action
]]>Quick question: would it be more efficient for a script that is executed lots of times per second to get data with…
Might sound kinda stupid, but just to be sure…
]]>With the gesture script by Lukas Morawietz and now floating desktops on V12.6, it should be possible to create a…
Possible use-cases:
– quick dialer when in contacts/dialer app (more intuitive than T9)
– faster access to text search when in browser/news reader apps (no need to pull up keyboard, find text input field, etc.)
– quick search of music/playlists when in listviews
Has anyone achieved something similar or has interest to?
]]>