]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/e17/e17-gpe-menu-convert/e17-gpe-menu-convert.sh
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / e17 / e17-gpe-menu-convert / e17-gpe-menu-convert.sh
1 #!/bin/sh
2
3 setVar() {
4     if [ ! "$value" = "" ]; then
5         name=`echo "$name" | sed 'y:-\[\]:_____:'`
6         value=`echo "$value" | sed 's:":\\\":g'`
7         export $name="$value"
8     fi
9 }
10
11 #convert true/false to 1/0
12 bool() {
13     if [ ! "$1" = "" ]; then
14         if [ "$1" = "True" ]; then
15             cmd="$cmd $2 1"
16         else
17             cmd="$cmd $2 0"
18         fi
19     fi
20 }
21
22 str() {
23     if [ ! "$1" = "" ]; then
24         cmd="$cmd $2 \"$1"\"
25     fi
26 }
27
28 convert_desktop_to_eap() {
29     echo "Adding $1 to e menu"
30     for l in `cat $1`; do
31         #on empty line clear vars
32         if [ "$l" = "" ]; then
33
34             #grab previous var if it exists
35             setVar
36
37             name=""
38             value=""
39         else
40             #if an = is in the line it's a name/value pair
41             if echo "$l" | grep -q "="; then
42
43                 #grab previous var if it exists
44                 setVar
45
46                 name=`echo "$l" | cut -d "=" -f 1`
47                 value=`echo "$l" | cut -d "=" -f 2-`
48             else
49
50                 #if previous value assume this is a continuation
51                 if [ ! "$value" = "" ]; then
52                     value="$value $l"
53                 fi
54             fi
55         fi
56     done
57     setVar
58
59     cmd=""
60
61     #set up options
62     bool "$StartupNotify" -set-startup-notify
63     str "$Name" -set-name
64     str "$Comment" -set-comment
65     str "$Exec" -set-exe
66
67     if [ ! "$cmd" = "" ]; then
68         eapFile="$PATH_TO_EAP/$2"
69         if [ -e $eapFile ]; then
70             echo "EAP file for $2 already created";
71         else
72             echo "Converting $1 to $2"
73             #cp ~/.e/e/applications/all/aterm.eap gpe-othello.eap
74             ##empty out eap file
75             ##enlightenment_eapp | grep -- -set- | cut -d " " -f 3 | xargs -iCMD enlightenment_eapp gpe-othello.eap CMD \"\"
76             #enlightenment_eapp gpe-othello.eap -del-all
77
78             cat <<EOF > /tmp/gpeEap.edc
79 images {
80     image: "$Icon" COMP;
81 }
82 collections {
83     group {
84         name: "icon";
85         max: 48 48;
86         parts {
87             part {
88                 name: "image";
89                 mouse_events: 0;
90                 description {
91                     state: "default" 0.0;
92                     aspect: 1.0 1.0;
93                     image.normal: "$Icon";
94                 }
95             }
96         }
97     }
98 }
99 EOF
100
101             edje_cc --image_dir "$PATH_TO_PIXMAPS" /tmp/gpeEap.edc "$eapFile"
102             rm /tmp/gpeEap.edc
103
104             cmd="enlightenment_eapp \"$eapFile\" $cmd"
105
106             #pipe command in sh to allow it to re-interpret quotes
107             echo $cmd | /bin/sh -s
108         fi
109
110         if `echo "$Categories" | grep -q "SystemSettings"`; then
111             dir="Settings"
112         elif `echo "$Categories" | grep -q "PIM"`; then
113             dir="PIM"
114         elif `echo "$Categories" | grep -q "Network"`; then
115             dir="Network"
116         elif `echo "$Categories" | grep -q "Games"`; then
117             dir="Games"
118         elif `echo "$Categories" | grep -q "Game"`; then
119             dir="Games"
120         elif `echo "$Categories" | grep -q "AudioVideo"`; then
121             dir="Multimedia"
122         elif `echo "$Categories" | grep -q "Panel"`; then
123             dir="Utility/Panel"
124         elif `echo "$Categories" | grep -q "Utility"`; then
125             dir="Utlity"
126         else
127             dir=""
128         fi
129
130         #dir=`echo "$Categories" | sed 'y:;:/:'`
131         mkdir -p "$PATH_TO_E_GPE/$dir"
132         orderFile="$PATH_TO_E_GPE/$dir"/.order
133         add=1
134         if [ -e "$orderFile" ]; then
135             if grep -q "$2" "$orderFile"; then
136                 echo "$2 is already in the $dir menu"
137                 add=0
138             fi
139         fi
140         if [ "$add" -eq 1 ]; then
141             echo "Adding $2 to $dir menu"
142             echo "$2" >> "$orderFile"
143         fi
144     fi
145 }
146
147 PATH_TO_DESKTOP="/usr/share/applications"
148 PATH_TO_PIXMAPS="/usr/share/pixmaps"
149 PATH_TO_EAP="/home/root/.e/e/applications/all"
150 PATH_TO_E_GPE="/home/root/.e/e/applications/favorite/GPE"
151
152 if [ ! -d $PATH_TO_E_GPE ]; then
153     mkdir -p $PATH_TO_E_GPE
154 fi
155 if [ ! -d $PATH_TO_EAP ]; then
156     mkdir -p $PATH_TO_EAP
157 fi
158 cd "$PATH_TO_DESKTOP"
159 for f in `ls *.desktop`; do
160     eap=`echo "$f" | cut -d . -f 1`
161     convert_desktop_to_eap "$PATH_TO_DESKTOP/$f" "$eap.eap"
162 done