Pinnwand-Verknuepfung erstellen/nl

Een pinbord link of bookmark dient om programma's te kunnen starten.

Basisbegrippen
Pinbord link's zijn te vinden in de directory ~/.appdata/tiitoo-pinnwand/tiitoo-localbookmarks. Voor iedere link zijn er drie bestanden in deze directory opgeslagen:
 * desktop-bestand: bevat de link naar Desktop Entry Specification
 * Icon: Grafisch bestand met afmeting 168x105
 * pprop-bestand: wordt door het pinbord aangemaakt

Een voorbeeld van een desktop-bestand zou er als volgt uit kunnen zien: [Desktop Entry] Type=Application Name=xfce4-appfinder Exec=xfce4-appfinder Icon=xfce4-appfinder.png Als het Name-veld aanwezig is, voegt het pinbord in de onderste helft van het icon een grijs vlak in, met de bit-getal waarde van het veld als tekst weergegeven.

Interactieve Widgets zijn QT-Library-bestanden (lib*.so) en hebben elk een eigen directory onder /usr/lib/tiitoo/apps. Dit wordt door de script aangemaakt en het lib-bestand wordt daar neergezet.

Bovendien wordt er een entry in de SQLite databank /var/tiitoo/pinnwand/pinnwand.db.sqlite aangemaakt.

Script add-widget.sh
Dit script legt de link naar het pinbord. Dit kan nuttig zijn als het programma niet vanuit de WeTab Market geïnstalleerd wordt.

Om Start-Widgets (Links naar programma's) te installeren, kan dit als gebruiker of als root worden uitgevoerd.

App-Widgets (interaktive Widgets) moeten als root geïnstalleerd worden.


 * 1) !/bin/bash


 * 1) pinboard widget installer by hamstiglue
 * 2) install widgets on your wetab pinboard:
 * 3) starter icons:
 * 4) add-widget.sh [ -f ]  [ ]
 * 5) * -f          forces to overwrite an existing widget with the same widgetname
 * 6) * widgetname: just a name for internal use, must be unique
 * 7) * picture:    path to picture shown on your pinboard, must be of size 168x105 pixels
 * 8) * binary:     name of program to be executed
 * 9) * aguments:   optional arguments to program
 * 10) bookmark icons:
 * 11) add-widget.sh [ -f ]  [ ]
 * 12) * -f            forces to overwrite an existing widget with the same widgetname
 * 13) * bookmarkname: just a name for internal use, must be unique
 * 14) * picture:      path to picture shown on your pinboard, must be of size 168x105 pixels
 * 15) * url:          url to be launched
 * 16) real widgets:
 * 17) add-widget.sh [ -f | -u ] 
 * 18) * -f            forces to overwrite an existing widget with the same widgetname
 * 19) * -u            uninstalls the widget
 * 20) * libwidget.so: name of the widget library to be installed or uninstalled
 * 1) * -f            forces to overwrite an existing widget with the same widgetname
 * 2) * bookmarkname: just a name for internal use, must be unique
 * 3) * picture:      path to picture shown on your pinboard, must be of size 168x105 pixels
 * 4) * url:          url to be launched
 * 5) real widgets:
 * 6) add-widget.sh [ -f | -u ] 
 * 7) * -f            forces to overwrite an existing widget with the same widgetname
 * 8) * -u            uninstalls the widget
 * 9) * libwidget.so: name of the widget library to be installed or uninstalled
 * 1) * -f            forces to overwrite an existing widget with the same widgetname
 * 2) * -u            uninstalls the widget
 * 3) * libwidget.so: name of the widget library to be installed or uninstalled
 * 1) * libwidget.so: name of the widget library to be installed or uninstalled

if [ $UID -gt 0 ] ; then USERNAME=$USER else source /var/tiitoo/registration/device_registered fi

APPPATH=/home/$USERNAME/.appdata/tiitoo-pinnwand/tiitoo-localbookmarks LIBPATH=/usr/lib/tiitoo/apps SQLITEDB=/var/tiitoo/pinnwand/pinnwand.db.sqlite SQLITEBIN=/usr/bin/sqlite3

if [ "$1" == "-f" ] ; then FORCE_OVERWRITE=1 shift else FORCE_OVERWRITE=0 fi

if [ "$1" == "-u" ] ; then UNINSTALL=1 shift else UNINSTALL=0 fi

WIDGETNAME="$1" WIDGETPIC="$2" WIDGETBIN="$3" WIDGETARGS="$4" WIDGETEXISTS=0

if [ -z "$WIDGETNAME" ] ; then echo "usage: add-widget.sh [ -f ]  [ ]" echo "  or: add-widget.sh [ -f ]  [ ]" echo "  or: add-widget.sh [ -f | -u ] " exit 1; fi

if echo "$WIDGETNAME" | egrep "lib.+\.so" >/dev/null 2>&1 ; then LIBMODE=1 else LIBMODE=0 fi

if echo "$WIDGETBIN" | egrep "^https?://" >/dev/null 2>&1 ; then URLMODE=1 else URLMODE=0 fi

if [ $LIBMODE -eq 1 ] ; then

if [ $UID -gt 0 ] ; then echo "please run as root" exit 1; fi

WIDGETFILE="$WIDGETNAME" WIDGETLIB="$(basename "$WIDGETFILE")" WIDGETNAME="$(basename "$WIDGETLIB" .so)" WIDGETNAME="$(echo "$WIDGETNAME" | cut -c4-)" WIDGETPRE="4tiitoo" WIDGETPATH="$LIBPATH/$WIDGETPRE-$WIDGETNAME" WIDGETDEST="$WIDGETPATH/$WIDGETLIB" WIDGETUUID="$(echo "$WIDGETDEST" | md5sum | perl -pe 's/(.{8})(.{4})(.{4})(.{4})(.{12}) .+/$1-$2-$3-$4-$5/')"

if [ $UNINSTALL -eq 1 ] ; then

$SQLITEBIN $SQLITEDB "delete from apprecord where userId = '$USERNAME' and PkgName = '$WIDGETPRE-$WIDGETNAME';" $SQLITEBIN $SQLITEDB "delete from widgetrecord where userId = '$USERNAME' and appPkgName = '$WIDGETPRE-$WIDGETNAME';"

if [ -e "$WIDGETDEST" ] ; then rm -f "$WIDGETDEST" rmdir "$WIDGETPATH" killall tiitoo-pinnwand fi   exit 0; fi

if [ ! -e "$WIDGETFILE" ] ; then echo "file '$WIDGETFILE' doesn't exist" exit 1; fi if [ -e "$WIDGETDEST" ] ; then WIDGETEXISTS=1 fi

else # LIBMODE=0

if [ -z "$WIDGETPIC" ] ; then echo "need widgetpicture (168x105 png file)" exit 1; fi if [ ! -r "$WIDGETPIC" ] ; then echo "file '$WIDGETPIC' doesn't exist" exit 1; fi if [ $URLMODE -eq 0 ] ; then if [ -z "$WIDGETBIN" ] ; then echo "need widgetbinary" exit 1; fi

WIDGETBIN="$(which "$WIDGETBIN")" if [ ! -e "$WIDGETBIN" ] ; then echo "file '$WIDGETBIN' doesn't exist" exit 1; fi   if [ ! -x "$WIDGETBIN" ] ; then echo "file '$WIDGETBIN' isn't executable" exit 1; fi   if [ -n "$WIDGETARGS" ] ; then WIDGETBIN="$WIDGETBIN " fi fi  if [ -e "$APPPATH/$WIDGETNAME.desktop" ] ; then WIDGETEXISTS=1 fi fi if [ $WIDGETEXISTS -gt 0 ] && [ $FORCE_OVERWRITE -eq 0 ] ; then echo "widget '$WIDGETNAME' already exists, use -f to overwrite" exit 1; fi

if [ $LIBMODE -eq 1 ] ; then

mkdir -p "$WIDGETPATH" chmod 755 "$WIDGETPATH" cp -p "$WIDGETFILE" "$WIDGETDEST" chmod 644 "$WIDGETDEST" chown -R root.root "$WIDGETPATH" ID_OLD=$($SQLITEBIN -list $SQLITEDB "select max(id) from widgetrecord;") ID_NEW="$ID_OLD" TRIES=100 su - $USERNAME -c "dbus-send --session --type=method_call --dest=com.tiitoo.Pinnwand /com/tiitoo/Pinnwand com.tiitoo.Pinnwand.CreateBookmark string: string: string:"

while [ "$ID_OLD" == "$ID_NEW" ] ; do

usleep 100000

ID_NEW=$($SQLITEBIN -list $SQLITEDB "select max(id) from widgetrecord;")

NEWFILE="$(egrep -l "^childId=$ID_NEW$" $APPPATH/bookmark-*.pprop 2>/dev/null)" if [ ! -n "$NEWFILE" ] || \ [ ! -e "$NEWFILE" ] ; then ID_NEW="$ID_OLD" fi

TRIES=$(($TRIES - 1)) if [ $TRIES -eq 0 ] ; then ID_NEW=0 fi

done

usleep 100000 if [ "$ID_NEW" -gt 0 ] ; then POSX=$($SQLITEBIN -list $SQLITEDB "select posX from widgetrecord where id = $ID_NEW;") POSY=$($SQLITEBIN -list $SQLITEDB "select posY from widgetrecord where id = $ID_NEW;") $SQLITEBIN $SQLITEDB "delete from widgetrecord where id = $ID_NEW;" NEWFILE="$(basename $NEWFILE .prop)" rm -f "$APPPATH/$NEWFILE.*" else POSX=0 POSY=0 fi $SQLITEBIN $SQLITEDB "insert into widgetrecord (userId, appPkgName, posX, posY, isChild) values ('$USERNAME', '$WIDGETPRE-$WIDGETNAME', $POSX, $POSY, 0);" $SQLITEBIN $SQLITEDB "insert into apprecord (uuid, userId, PkgName, naturalName) values ('$WIDGETUUID', '$USERNAME', '$WIDGETPRE-$WIDGETNAME', '$WIDGETPRE-$WIDGETNAME');"

else # LIBMODE=0

if [ $URLMODE -eq 1 ] ; then WIDGETTYPE=Link WIDGETMAIN=URL WIDGETDESC="$WIDGETARGS" WIDGETARGS="" else WIDGETTYPE=Application WIDGETMAIN=Exec WIDGETDESC="" fi

cp $WIDGETPIC $APPPATH/$WIDGETNAME.png echo "[Desktop Entry]"                   > $APPPATH/$WIDGETNAME.desktop echo "Type=$WIDGETTYPE"                 >> $APPPATH/$WIDGETNAME.desktop echo "Icon=$WIDGETNAME.png"             >> $APPPATH/$WIDGETNAME.desktop echo "Name=$WIDGETDESC"                 >> $APPPATH/$WIDGETNAME.desktop echo "$WIDGETMAIN=$WIDGETBIN$WIDGETARGS" >> $APPPATH/$WIDGETNAME.desktop chmod 664 $APPPATH/$WIDGETNAME.* chown $USERNAME.$USERNAME $APPPATH/$WIDGETNAME.*

fi

killall tiitoo-pinnwand

Kijk ook op

 * GUI-Frontend