User Tools

Site Tools


script_desktop_bookmark_modifier

====== About the script ====== * Purpose : This script allows you to modify desktop bookmarks and 'go to specified desktop&position' shortcuts, or even make new ones in an easier way. * Author : [[https://plus.google.com/u/1/105066926163073195690|TrianguloY]] * Link: https://plus.google.com/u/1/105066926163073195690/posts/PoavgDd7WW7 ====== How to use the script ====== If you use the launcher's ability to create them, you need to be in the desired position while creating it, and if you want to modify a created one with the app/select shortcut, you need to move it first so you can select it. This script allows you to set the data of the shortcut to a previously saved one. It modify the launcher 'go to container and position' shortcut, you don't need this script after setting it, this is just a tool. (If you want to set multiple shortcuts in one, check my [[script_multi_container_bookmark|multi-container bookmark]]) Instructions: * Get the position: * Once the container is where you want, run the script (by default: long click the background, script, select) * If the container is not the desktop, it will ask. Cancel to select the desktop instead. * Apply the position * Run the script from the desired item (by default: long click the item, script, select) * If the item is not a desktop bookmark shortcut it will ask for confirmation. You can accept to convert it. * Confirm and the shortcut data will be override with the previously saved one. ====== Script code ====== <sxh javascript> var e=LL.getEvent(); var item=e.getItem(); if(item!=null){ var saved=LL.getScriptTag(); if(saved==null){ alert("No data saved.\nRun this script from a container first."); return; } saved=JSON.parse(saved); if(item.getType()!="Shortcut"){ alert("This item is not a Shortcut"); return; } if(!isBookmark(item.getIntent())){ if (!confirm("This shortcut is not a Desktop bookmark. Do you want to continue? (This will override the item's intent)"))return; }else{ //if(confirm("Do you want to save the current data } if(!confirm("Data found:\nContainer Id: "+saved.p+"\nPosition X: "+saved.x+"\nPosition Y: "+saved.y+"\nScale: "+saved.s+"\n\n Do you want to apply it?"))return; item.setIntent(Intent.parseUri("#Intent;component=net.pierrox.lightning_launcher_extreme/net.pierrox.lightning_launcher.activities.Dashboard;i.p="+saved.p+";f.s="+saved.s+";f.x="+saved.x+";f.y="+saved.y+";end",0).setAction(null)); Android.makeNewToast("Applied correctly",true).show(); }else{ //no item, let's save var cont=e.getContainer(); if(cont.getType()!="Desktop")if(!confirm("The container selected is not the desktop, do you want to use it instead? (cancel to use the current desktop)"))cont=LL.getCurrentDesktop(); var data={}; data.p=cont.getId(); data.s=cont.getPositionScale(); data.x=-cont.getPositionX()*data.s; data.y=-cont.getPositionY()*data.s; LL.setScriptTag(JSON.stringify(data)); Android.makeNewToast("Data saved:\nContainer Id: "+data.p+"\nPosition X: "+data.x+"\nPosition Y: "+data.y+"\nScale: "+data.s,false).show(); } function isBookmark(i){ return i.getComponent().flattenToString()=="net.pierrox.lightning_launcher_extreme/net.pierrox.lightning_launcher.activities.Dashboard" && i.hasExtra('p') && i.hasExtra('s') && i.hasExtra('x') && i.hasExtra('y') } </sxh>

script_desktop_bookmark_modifier.txt · Last modified: 2015/01/20 18:06 by trianguloy