gen_desktop_layout.sh
#1) run command to get the following list, and remove the un-necessary lines => sqlite3  launcher.db "select * from favorites;"
#2) run me to get test.xml and put content to the default.. file.
line='1|com.miui.home:string/default_folder_title_tools||-100|3|2|3|1|1|2|-1||||||||1||0
3|音乐|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.miui.player/.ui.MusicBrowserActivity;end|-100|3|2|2|1|1|0|-1|||com.miui.player|||||1||0
4|设置|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.settings/.Settings;end|-100|3|0|3|1|1|0|-1|||com.android.settings|||||1||0
5|文件管理|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.fileexplorer/.FileExplorerTabActivity;end|-100|3|1|3|1|1|0|-1|||com.android.fileexplorer|||||4||0
6|系统更新|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.updater/.MainActivity;end|1||||1|1|0|-1|||com.android.updater|||||1||0
7|时钟|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.deskclock/.DeskClock;end|1||||1|1|0|-1|||com.android.deskclock|||||1||0
8|备份|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.miui.backup/.BackupActivity;end|1||||1|1|0|-1|||com.miui.backup|||||5||0
9|流量监控|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.monitor/.MainActivity;end|1||||1|1|0|-1|||com.android.monitor|||||1||0
10|主题风格|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.thememanager/.ThemeResourceTabActivity;end|-100|3|3|2|1|1|0|-1|||com.android.thememanager|||||5||0
11|电子市场|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.vending/.AssetBrowserActivity;end|-100|4|1|1|1|1|0|-1|||com.android.vending|||||2||0
12|Gmail|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.google.android.gm/.ConversationListActivityGmail;end|-100|4|2|1|1|1|0|-1|||com.google.android.gm|||||1||0
13|日历|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.calendar/.LaunchActivity;end|-100|4|0|2|1|1|0|-1|||com.android.calendar|||||1||0
14|GoogleTalk|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.google.android.talk/.SigningInActivity;end|-100|4|0|1|1|1|0|-1|||com.google.android.talk|||||2||0
15|拨号|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.contacts/.activities.TwelveKeyDialer;end|-101|0|0|0|1|1|0|-1|||com.android.contacts|||||7||0
16|联系人|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.contacts/.activities.PeopleActivity;end|-101|0|1|0|1|1|0|-1|||com.android.contacts|||||4||0
17|浏览器|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.browser/.BrowserActivity;end|-101||||1|1|0|-1|||com.android.browser|||||6||0
18|信息|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.mms/.ui.MmsTabActivity;end|-101|0|2|0|1|1|0|-1|||com.android.mms|||||5||0
19|搜索|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.google.android.googlequicksearchbox/.SearchActivity;end|-100|4|3|1|1|1|0|-1||0|com.google.android.googlequicksearchbox|||||1||0
20|录像|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.sec.android.app.videoplayer/.activity.MainTab;end|-100|4|1|0|1|1|0|-1||0|com.sec.android.app.videoplayer|||||1||0
21|下载管理|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.providers.downloads.ui/.DownloadList;end|-100|4|3|3|1|1|0|-1||0|com.android.providers.downloads.ui|||||1||0
22|录音机|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.sec.android.app.voicerecorder/.VoiceRecorderMainActivity;end|-100|4|3|0|1|1|0|-1||0|com.sec.android.app.voicerecorder|||||1||0
23|防打扰|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.miui.antispam/.firewall.FirewallTab;end|-100|4|2|3|1|1|0|-1||0|com.miui.antispam|||||1||0
24|图库|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.cooliris.media/.Gallery;end|-100|3|1|2|1|1|0|-1||0|com.cooliris.media|||||1||0
25|计算机|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.sec.android.app.calculator/.Calculator;end|-100|4|1|2|1|1|0|-1||0|com.sec.android.app.calculator|||||1||0
26|用户反馈|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.miui.bugreport/.BugReportActivity;end|1|-1|-1|0|1|1|0|-1||0|com.miui.bugreport|||||1||0
27|时钟|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.sec.android.app.clockpackage/.ClockPackage;end|-100|4|2|2|1|1|0|-1||0|com.sec.android.app.clockpackage|||||1||0
28|照相机|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.sec.android.app.camera/.Camera;end|-100|3|0|2|1|1|0|-1||0|com.sec.android.app.camera|||||2||0
29|FM收音机|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.sec.android.app.fm/.MainActivity;end|-100|4|2|0|1|1|0|-1||0|com.sec.android.app.fm|||||2||0
30|手电筒|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=net.cactii.flash2/.MainActivity;end|1|-1|-1|0|1|1|0|-1||0|net.cactii.flash2|||||1||0
31|Superuser|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.noshufou.android.su/.Su;end|1|-1|-1|0|1|1|0|-1||0|com.noshufou.android.su|||||1||0
32|录音机|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.soundrecorder/.SoundRecorder;end|-100|4|0|0|1|1|0|-1||0|com.android.soundrecorder|||||1||0
33|指南针|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.miui.compass/.CompassActivity;end|-100|4|0|3|1|1|0|-1||0|com.miui.compass|||||1||0
34|任务管理器|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.sec.android.app.controlpanel/.activity.JobManagerActivity;end|-100|4|1|3|1|1|0|-1||0|com.sec.android.app.controlpanel|||||1||0
35|便签|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.miui.notes/.ui.NotesListActivity;end|-100|4|3|2|1|1|0|-1||0|com.miui.notes|||||1||0
36|应用超市|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.miui.supermarket/.MainTabActivity;end|-100|3|3|3|1|1|0|-1||0|com.miui.supermarket|||||2||0
37|CWM|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=eu.chainfire.cfroot.cwmmanager/.MainActivity;end|1|-1|-1|0|1|1|0|-1||0|eu.chainfire.cfroot.cwmmanager|||||2||0
38|搜索|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.quicksearchbox/.SearchActivity;end|1|-1|-1|0|1|1|0|-1||0|com.android.quicksearchbox|||||1||0'

for l in $line; do
        name=`echo $l | cut -f2 -d"|"`
        class=`echo $l | cut -f3 -d"|" | sed -e "s/.*component=//" -e "s/;end//" -e "s/\///g"`
        c=`echo $l | cut -f4 -d"|"`
        screen=`echo $l | cut -f5 -d"|"`
        let screen=$screen-2
        x=`echo $l | cut -f6 -d"|"`
        y=`echo $l | cut -f7 -d"|"`
        package=`echo $l | cut -f14 -d"|"`
        if [ -z "$screen" ]; then
                screen=-1000
        fi
        if [ "$screen" -lt 0  ]; then
                echo "<favorite launcher:className=\"$class\" launcher:packageName=\"$package\" launcher:container=\"$c\" launcher:x=\"$x\" launcher:y=\"$y\" />" >> test.xml
        else
                echo "<favorite launcher:className=\"$class\" launcher:packageName=\"$package\" launcher:screen=\"$screen\" launcher:x=\"$x\" launcher:y=\"$y\" />" >> test.xml
        fi
done
