Archives for: July 2008

07/15/08

Permalink 07:29:13 pm, by neilb Email , 723 words, 4270 views   English (US)
Categories: Developing for the Eee

Adding a UI Entry in a package

More on the process of packaging. Here is how to automatically add an entry into the desktop that will launch an application in your package.

If you have developed any UI code for the Eee PC, you are likely aware that the Eee PC stores its desktop entries in a file called


/opt/xandros/share/AsusLauncher/simpleui.rc.

Take a look at this file on your system. It is an XML format file. Each entry is composed of a block of XML of the element <parcel>, so for example here is the entry for firefox



<parcel simplecat="Internet" shortcut="/opt/firefox/firefox.desktop"
icon="web_norm.png"
selected_icon="web_hi.png">
<name lang="en">Web
<name lang="zh_TW">網路瀏覽器
<name lang="zh_CN">网页浏览器
<name lang="es_AR">Web
<name lang="de_DE">Web
<name lang="es_ES">Web
<name lang="fr_FR">Web
<name lang="it_IT">Web
<name lang="nl_NL">Web
<name lang="pt_PT">Internet
<name lang="ru_RU">Веб
<name lang="th_TH">เว็บ
<name lang="tr_TR">Web
</parcel>

This adds the firefox application to the Internet page of the desk top and associates icons for the selected and unselected states. The various names entries add names for various languages.

So to add a UI entry, we need the package to automatically add a parcel entry to the simpleui.rc file for your application.

Since XML uses end tags to close off the data format we need to effectively edit the file (as opposed to just appending to the file). The best tool to use is therefgore sed. Here is some sed code that automatically adds an entry to the UI.


sed -e '/<\/simpleui>/i\
<!-- MySpecialProgram version=1.0 { -->\
<parcel simplecat="Play" extraargs="/usr/bin/sudo /home/user/bin/myspecialprogram" \
icon="sysinfo_norm.png" \
selected_icon="sysinfo_hi.png"> \
<name lang="en">My Special Program</name>\
<name lang="zh_TW">My Special Program</name>\
<name lang="zh_CN">My Special Program</name>\
<desc lang="en">Does some cool stuff</desc>\
</parcel> \
\
' simpleui.rc

This code inserts a chunk of XML prior to the end of the UI control file that will add an entry to the “Play” tab to run the program /home/user/bin/myspecialprogram. In this case, I’ve assumed that myspecialprogram does some system stuff and so is launched with sudo. I’ve used the technique of wrapping the XML block in structured comments. This allows future edits to the UI file to move the XML block and yet it can still be located.

Of course, your users may not actually like your app and want to uninstall it. Here is the code to do just that.


sed -e '/<!-- MyTool version=1.0 {/,/<!-- } MyTool version=1.0 -->/d' /opt/xandros/share/AsusLauncher/simpleui.rc

To use this as part of the package we need to call the code from the scripts in the package DEBIAN directory. I use the postinst script file to perform the add and the prerm script to do the remove. So in the package DEBIAN directory

put the file postinst with the code


#! /bin/sh
sed -e '/<\/simpleui>/i\
<!-- MySpecialProgram version=1.0 { -->\
<parcel simplecat="Play" extraargs="/usr/bin/sudo /home/user/bin/myspecialprogram" \
icon="sysinfo_norm.png" \
selected_icon="sysinfo_hi.png"> \
<name lang="en">My Special Program</name>\
<name lang="zh_TW">My Special Program</name>\
<name lang="zh_CN">My Special Program</name>\
<desc lang="en">Does some cool stuff</desc>\
</parcel> \
<!-- } MySpecialProgram version=1.0 -->\
' /opt/xandros/share/AsusLauncher/simpleui.rc > /tmp/lidman-simpleui.rc
mv /tmp/lidman-simpleui.rc /opt/xandros/share/AsusLauncher/simpleui.rc

and put the file prerm with the following contents


#! /bin/sh
sed -e '/<!-- MyTool version=1.0 {/,/<!-- } MyTool version=1.0 -->/d' /opt/xandros/share/AsusLauncher/simpleui.rc
mv /tmp/lidman-simpleui.rc /opt/xandros/share/AsusLauncher/simpleui.rc

NOTE that both files use the absolute location of the simpleui.rc file.

As a final piece, ensure that the package depends on “sed” by putting


Depends: sed

in the DEBIAN/control file. This is a just for completeness issue. Eee PCs come with sed installed.

More on packaging to follow in future blog entries.

07/13/08

Permalink 09:14:19 pm, by neilb Email , 349 words, 11000 views   English (US)
Categories: Developing for the Eee, Cool Eee

Using USB-Audio

Setting up an external usb device for use with the eeepc music manager (aka amarok) can be challenging. The following steps should work. Unfortunately, you will need to use the command line.

Ensure your usb audio player is plugged in and powered up. I have an m-audio audiophile.

m-audio audiophile usb

Type control-t to bring up the terminal to enter commands.

Into the terminal window, type:


cat /proc/asound/cards

This will list the target cards that can be used by the music manager. Your usb device should be listed. If not, check cabling and that the device is powered up and working. If the device is not listed in this list none of the following steps will work. I’ll assume that you only have the standard device and your usb device. Therefore your card should also be numbered card 1.

Now edit the file ~/.asoundrc. BTW the ~ is a short cut for your home directory.

If you have a favourite editor use that, otherwise type the following into the terminal window:

kate ~/.asoundrc

Kate is an easy to use visual editor. Add the following lines.


pcm.intel8x0 {
type plug
slave.pcm "hw:0"
}

ctl.intel8x0 {
type hw
card 0
}

pcm.usb-audio {
type plug
slave.pcm "hw:1"
}

ctl.usb-audio {
type hw
card 1
}

This associates card 1 with the name usb-audio. If your card is not card 1, then change each of the two 1s in the pcm.usb-audio and ctl.usb-audio sections.

Now save the file and start up the music manager (if it was already running, restart it).

Select the Setting/Configure Music Manager… dialog and the engine tab.

If the xine engine is not in use, select it and hit the apply button. If alsa is not the selected output plugin, then select it from the drop-down and hit apply.

In the stereo field, type:

usb-audio

and hit apply.

Eeepc Music Manager Engine Settings

Your usb-audio device should now be the target of your eeepc music manager. You should now be able to enjoy music via your usb-audio device.

To change back, use default as the stereo field value. If you run into problems, delete the ~/.asoundrc file.

Digital Annealing Eee PC Blog


July 2008
Sun Mon Tue Wed Thu Fri Sat
 << < Current> >>
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Search

Choose skin

Linkblog

Misc

XML Feeds

What is RSS?

Who's Online?

  • Guest Users: 25

powered by b2evolution free blog software