improved version
authorjbollo <jose.bollo@eurogiciel.fr>
Wed, 17 Apr 2013 13:43:58 +0000 (15:43 +0200)
committerjbollo <jose.bollo@eurogiciel.fr>
Wed, 17 Apr 2013 13:43:58 +0000 (15:43 +0200)
load_widget.sh

index 849a3da..c55299f 100644 (file)
@@ -1,80 +1,42 @@
 #! /bin/sh
 
 repo=/opt/usr/apps/
+chmod -R a+rw /opt/dbspace/
+
+dbwdgt() {
+cat << EOC
+33CFo0eFJe  Annex
+yKrWwxz1KX  Mancala
+ewqPdCunAO  BubbleWrap
+SM31mV8fq9  Go
+EOC
+}
 
-load_widget()
-{
-    chmod -R a+rw /opt/dbspace/
-    for args in `ls $repo` ; do
-        if [ $args != "tmp" ]
-        then
-            echo "    - loading $args"
-            echo "---------------------------------------------"
-           chmod a+x $repo/$args/bin/*
-            if [ $args == "33CFo0eFJe" ] ; then 
-               annex
-           fi
-           if [ $args == "yKrWwxz1KX" ] ; then 
-               mancala
-           fi
-           if [ $args == "ewqPdCunAO" ] ; then 
-               bubble
+dbwdgt |
+while read id name
+do
+    bin=$(ls /opt/usr/apps/$id/bin/$id.*)
+    for x in /opt/usr/apps/$id/res/wgt/*[iI][cC][oO][nN]*; do
+       if [[ -f $x ]]; then
+           res=$(file -b $x|cut -d , -f 2|tr -d ' '|egrep '[0-9]+x[0-9]+')
+           if [[ -n "$res" ]]; then
+               diric=/usr/share/icons/hicolor/$res/apps
+               [[ -d $diric ]] || mkdir -p $diric
+               cp $x $diric/$name.png
            fi
-           if [ $args == "SM31mV8fq9" ] ; then 
-               go
-           fi
-           echo ""
-        fi
+       fi
     done
-}
-
-annex()
-{
-    cp /opt/usr/apps/33CFo0eFJe/res/wgt/annex-icon.png /usr/share/icons/hicolor/128x128/apps/annex.png
-cat<<EOF | tee /usr/share/applications/annex.desktop
-[Desktop Entry]
-Type=Application
-Name=Annex
-Exec=/opt/usr/apps/33CFo0eFJe/bin/33CFo0eFJe.annex
-Icon=/usr/share/icons/hicolor/128x128/apps/annex.png
-EOF
-}
-
-mancala()
-{
-    cp /opt/usr/apps/yKrWwxz1KX/res/wgt/icon_128.png /usr/share/icons/hicolor/128x128/apps/mancala.png
-cat<<EOF | tee /usr/share/applications/mancala.desktop
+    desk=/usr/share/applications/$name.desktop
+    cat << EOC > $desk
 [Desktop Entry]
 Type=Application
-Name=Mancala
-Exec=/opt/usr/apps/yKrWwxz1KX/bin/yKrWwxz1KX.mancala
-Icon=/usr/share/icons/hicolor/128x128/apps/mancala.png
-EOF
-}
-
-bubble()
-{
-    cp /opt/usr/apps/ewqPdCunAO/res/wgt/icon_128.png /usr/share/icons/hicolor/128x128/apps/bubble.png
-cat<<EOF | tee /usr/share/applications/bubble.desktop
-[Desktop Entry]
-Type=Application
-Name=BubbleWrap
-Exec=/opt/usr/apps/ewqPdCunAO/bin/ewqPdCunAO.bubblewrap
-Icon=/usr/share/icons/hicolor/128x128/apps/bubble.png
-EOF
-}
-
-go()
-{
-    cp /opt/usr/apps/SM31mV8fq9/res/wgt/Go_Icon_128.png /usr/share/icons/hicolor/128x128/apps/go.png
-cat<<EOF | tee /usr/share/applications/go.desktop
-[Desktop Entry]
-Type=Application
-Name=Go
-Exec=/opt/usr/apps/SM31mV8fq9/bin/SM31mV8fq9.Go
-Icon=/usr/share/icons/hicolor/128x128/apps/go.png
-EOF
-}
+Name=$name
+Exec=$bin
+Icon=$name
+Terminal=false
+Categories=WRT;Game
+EOC
+done
 
+xdg-icon-resource forceupdate
 
-load_widget