View Single Post
Posts: 839 | Thanked: 3,386 times | Joined on Mar 2009
#1
I'm Requesting for comments about this solution to release/distribute/package Queen BeeCon Widgets inside debian-package.

Issues are described here:
http://wiki.maemo.org/Queen_BeeCon_W...ipts_please.3F

So far I have made first debian-package and pushed it to the extas-devel.
WARNING: It can ruin your working widgets (during installation, upgrading or removing). I have not installed it on my primary phone myself!
Package name is qbw-harmattan-date

With apt-get source qbw-harmattan-date you can get all files.
(http://maemo.org/packages/view/qbw-harmattan-date/)

I will describe how it is made so it can be analysed and potential failing parts could be spotted.
I'm using unmodified queen-beecon, but it can be tuned, if something can be then done more robust way.


I will use name HarmattanDate for this instructions. Name can't contain spaces or dashes.

-------
So...
You have good widget on your phone. Export it to the file (exported_widget.txt).
copy file "/var/lib/gconf/apps/osso/hildon-desktop/applets/XXX/%gconf.xml" (conf.xml) where XXX is something like queen-beecon.desktop-0. This file contains coordinates for widget.


on debian/rules:install
Code:
	mkdir -p $(CURDIR)/debian/qbw-harmattan-date/var/lib/gconf/apps/osso/hildon-desktop/applets/queen-beecon.desktop-HarmattanDate
	cp conf.xml $(CURDIR)/debian/qbw-harmattan-date/var/lib/gconf/apps/osso/hildon-desktop/applets/queen-beecon.desktop-HarmattanDate/%gconf.xml

	mkdir -p $(CURDIR)/debian/qbw-harmattan-date/opt/qbw-harmattan-date/
	cp exported_widget.txt $(CURDIR)/debian/qbw-harmattan-date/opt/qbw-harmattan-date/exported_widget

	#Optional: Add to another desktops also (tune also postinst/postrm)
	mkdir -p $(CURDIR)/debian/qbw-harmattan-date/var/lib/gconf/apps/osso/hildon-desktop/applets/queen-beecon.desktop-HarmattanDate2
	cp conf.xml $(CURDIR)/debian/qbw-harmattan-date/var/lib/gconf/apps/osso/hildon-desktop/applets/queen-beecon.desktop-HarmattanDate2/%gconf.xml
debian/postinst
Code:
#!/bin/sh

#Add new widget data (from exported_widget) to the .queen_beecon
echo >>  /home/user/.queen_beecon
echo "[queen-beecon.desktop-HarmattanDate]" >>  /home/user/.queen_beecon
tail -n +5 /opt/qbw-harmattan-date/exported_widget >> /home/user/.queen_beecon

#Add new entries to the 'header' of the .queen_beecon
#HarmattanDate is instanceTitle from exported_widget
#date ... is instanceCmd from exported_widget
sed -i  '/^c_titles/s|$|HarmattanDate;|' /home/user/.queen_beecon
sed -i  '/^c_commands/s|$|date +"%A, %-d/%m/%Y";|' /home/user/.queen_beecon

#Add icon to the desktop
echo "
[queen-beecon.desktop-HarmattanDate]
X-Desktop-File=/usr/share/applications/hildon-home/queen-beecon.desktop
">> /home/user/.config/hildon-desktop/home.plugins



#for another desktops.
#change InstanceTitle with sed (add postfix '2')
echo >>  /home/user/.queen_beecon
echo "[queen-beecon.desktop-HarmattanDate2]" >>  /home/user/.queen_beecon
tail -n +5 /opt/qbw-harmattan-date/exported_widget | sed 's/HarmattanDate/HarmattanDate2/' >> /home/user/.queen_beecon


sed -i  '/^c_titles/s|$|HarmattanDate2;|' /home/user/.queen_beecon
#no reason to add commnand again
#sed -i  '/^c_commands/s|$|date +"%A, %-d/%m/%Y";|' /home/user/.queen_beecon

echo "
[queen-beecon.desktop-HarmattanDate2]
X-Desktop-File=/usr/share/applications/hildon-home/queen-beecon.desktop
">> /home/user/.config/hildon-desktop/home.plugins

#push this another widget to desktop2
gconftool-2 --set /apps/osso/hildon-desktop/applets/queen-beecon.desktop-HarmattanDate2/view --type int 2




#these should be owned by user
chown user /home/user/.config/hildon-desktop/home.plugins
chown user /home/user/.queen_beecon

exit 0
debian/postrm
Code:
#!/bin/sh

#Do we need remove these?
#sed -i  '/^c_titles/s|$|HarmattanDate;|' /home/user/.queen_beecon
#sed -i  '/^c_commands/s|$|date +"%A, %-d/%m/%Y";|' /home/user/.queen_beecon

#Remove widget from the .config/hildon-desktop/home.plugins
#remove two subsequent rows 
#  [queen-beecon.desktop-HarmattanDate]
#  X-Desktop-File=/usr/share/applications/hildon-home/queen-beecon.desktop
sed -i ':a;N;$!ba;s/\[queen-beecon.desktop-HarmattanDate\]\nX-Desktop-File=\/usr\/share\/applications\/hildon-home\/queen-beecon.desktop//'  /home/user/.config/hildon-desktop/home.plugins

#Remove widget from the .queen_beecon
#We know the name of widget
#We think the last option for widget is empty updOnDBUSMatchRule=
#
#*Because every widget contains that 'updOnDBUSMatchRule=' and sed is greedy, it will eat every widget after what we are looking for
#  -> solution: use perl -pe with .*? so it stops on first 'updOnDBUSMatchRule='
#
#*It is multiline file and we want it works on 'single-line mode', but for some reason it won't work
#  -> solution, change every linebreak to the FOORAB (foobar might be in use). do the thing. change every FOORAB back to linebreak
cat /home/user/.queen_beecon | sed ':a;N;$!ba;s/\n/FOORAB/g' | perl -pe 's/\[queen-beecon.desktop-HarmattanDate\].*?updOnDBUSMatchRule=//' | sed 's/FOORAB/\n/g' > /root/.queen_beecon_temporary_file
mv /root/.queen_beecon_temporary_file /home/user/.queen_beecon





#for another desktops too
sed -i ':a;N;$!ba;s/\[queen-beecon.desktop-HarmattanDate2\]\nX-Desktop-File=\/usr\/share\/applications\/hildon-home\/queen-beecon.desktop//'  /home/user/.config/hildon-desktop/home.plugins

cat /home/user/.queen_beecon | sed ':a;N;$!ba;s/\n/FOORAB/g' | perl -pe 's/\[queen-beecon.desktop-HarmattanDate2\].*?updOnDBUSMatchRule=//' | sed 's/FOORAB/\n/g' > /root/.queen_beecon_temporary_file
mv /root/.queen_beecon_temporary_file /home/user/.queen_beecon






#these should be owned by user
chown user /home/user/.config/hildon-desktop/home.plugins
chown user /home/user/.queen_beecon

exit 0

Package will contain some files, and postinstallation/postrm are used for adding/deleting widget (or widgets, if many desktops are used). Removing package (i.e. running postrm) should be possible (and safe) even widget (or some of them) is reconfigured by user, or even manually removed.
 

The Following 13 Users Say Thank You to AapoRantalainen For This Useful Post: