Icon intricacies on the Eee PC

Eee PC LauncherTo install an app on an Eee PC running Xandros, it's necessary to conform to the Asus launcher standards and copy the correct icons and other information to the correct locations, from within the application's Debian installation script.

I have an early 701 machine and it's evident that a few things have changed since then, especially with the way icons are installed.

So, since I needed to make sure my apps do the right thing for more recent Eee PCs, I downloaded the SDK and after some messing with converting the 701 ISO to a virtual machine file, I finally got the 701 'emulator' working under VMware (on Windows XP).

I expected that the file system in the virtual machine would contain /etc/AsusLauncher/AsusLauncher.conf as documented in the SDK instructions, plus /opt/xandros/bin/update-launcher. But it doesn't - it seems to be halfway between the old 701 environment, and the new one. It does have 130x130 icons and not the 120x120 found on my older 701.

The solution for getting the newer launcher was to install the required Debian packages from http://update.eeepc.asus.com/p901/pool/. I had previously tried updating various packages via Add/Remove and that didn't do it. I downloaded and installed these packages (the order is important):

imagemagick_7%3a6.2.4.5.dfsg1-0.14_i386.deb
libxml2-utils_2.6.27.dfsg-1_i386.deb
asus-launcher-config_1.0.3-1_all.deb

I also attemped to install asus-launcher_0.173-1_i386.deb but dpkg said that this was older than the installed package.

I now have two virtual machines - one for an Eee PC with the updated launcher, and one without. Unfortunately an installation script has to deal with both situations since presumably there are millions of early Eee PCs in circulation without update-launcher. Not only that, it must detect whether to install 120x120 or 130x130 icons. For what it's worth, here is part of my current Debian post-installation script, for an application called Writer's Café. The function checks whether AsusLauncher.conf is present and if so, uses the new icon installation method copying an XML snippet, otherwise it changes simpleui.rc directly. It also checks whether old-style icons should be copied or the larger kind, by testing the size of one of the existing icons.

# Install icons for the simple interface
installeeepc_simpleui()
{
  XMLFOLDER=/opt/xandros/share/launcherxml
  LAUNCHERDIR=/opt/xandros/share/AsusLauncher
  NEWLAUNCHERDIR=/var/lib/AsusLauncher
  LAUNCHERCONF=/etc/AsusLauncher/AsusLauncher.conf

  SIMPLEUI=$LAUNCHERDIR/simpleui.rc
  NEWSIMPLEUI=$NEWLAUNCHERDIR/simpleui.rc

  # Test for differing icon size by looking at the file size of a PNG.
  # On early Eee PC systems (120x120 icon size) it is 11871, on later systems
  # (130x130 icon size) it is 15445.
  WEBNORMSIZE=`stat /opt/xandros/share/AsusLauncher/web_norm.png --printf "%s\n"`

  if [ "$WEBNORMSIZE" = "11871" ]; then
    ICONSIZE=120
  else
    ICONSIZE=130
  fi

  # Copy the icons
  cp -f "$INSTALLDIR/appicons/asus${ICONSIZE}x${ICONSIZE}/"*.png $LAUNCHERDIR

  if [ -f $LAUNCHERCONF ]; then
    # NEW METHOD

    # Check that /opt/xandros/share/launcherxml is in AsusLauncher.conf

    grep "launcherxml" $LAUNCHERCONF > /tmp/wctest

    if [ ! -s /tmp/wctest ]; then
      echo "/opt/xandros/share/launcherxml" >> $LAUNCHERCONF
    fi

    rm -f /tmp/wctest

    mkdir -p $XMLFOLDER

    cp $INSTALLDIR/writerscafe_eeepc.xml $XMLFOLDER

    if [ -f /opt/xandros/sbin/update-launcher ]; then
        /opt/xandros/sbin/update-launcher
    fi

  else
   
    # OLD METHOD

    if [ -f $SIMPLEUI ]; then

      # Check if we've already added the parcel
      grep "Writer's Caf" $SIMPLEUI > /tmp/wctest

      if [ ! -s /tmp/wctest ]; then
        cp $SIMPLEUI $SIMPLEUI.prewriterscafeinstall
        sed "s/<\/simpleui>//g" < $SIMPLEUI.prewriterscafeinstall > $SIMPLEUI.tmp
        cat $SIMPLEUI.tmp $INSTALLDIR/writerscafe_eeepc.xml > $SIMPLEUI
        echo "</simpleui>" >> $SIMPLEUI
        rm -f $SIMPLEUI.tmp

      fi

      rm -f /tmp/wctest
    fi 
  fi
}

And a function for the Debian pre-remove script to uninstall the icon:

uninstalleeepc_simpleui()
{
  XMLFOLDER=/opt/xandros/share/launcherxml
  LAUNCHERDIR=/opt/xandros/share/AsusLauncher
  NEWLAUNCHERDIR=/var/lib/AsusLauncher
  LAUNCHERCONF=/etc/AsusLauncher/AsusLauncher.conf

  SIMPLEUI=$LAUNCHERDIR/simpleui.rc
  NEWSIMPLEUI=$NEWLAUNCHERDIR/simpleui.rc

  rm -f $LAUNCHERDIR/writerscafe_norm.png $LAUNCHERDIR/business_writerscafe_hi.png

  if [ -f $LAUNCHERCONF ]; then
    # NEW METHOD

    rm -f $XMLFOLDER/writerscafe_eeepc.xml

    if [ -f /opt/xandros/sbin/update-launcher ]; then
        /opt/xandros/sbin/update-launcher
    fi
  else
    # OLD METHOD

    if [ -f $LAUNCHERDIR/simpleui.rc.prewriterscafeinstall ] ; then
      cp $LAUNCHERDIR/simpleui.rc $LAUNCHERDIR/simpleui.rc.prewriterscafeuninstall
      cp $LAUNCHERDIR/simpleui.rc.prewriterscafeinstall $LAUNCHERDIR/simpleui.rc
    fi
  fi
}

My XML parcel is this:

<parcel simplecat="Work" extraargs="/usr/bin/writerscafe2"
        icon="writerscafe_norm.png"
        selected_icon="writerscafe_hi.png">
        <name lang="en">Writer's Café</name>
        <name lang="zh_TW">Writer's Café</name>
        <name lang="zh_CN">Writer's Café</name>
        <desc lang="en">Creative writing tools from Anthemion Software</desc>
</parcel>

I also have a shell script for making Eee PC icons under Windows, based on information from this forum for using ImageMagick. This script is not part of the installation process, it's just a helper to create the icons in advance. To use it, install ImageMagick (and on Windows, MinGW's MSYS for running the script), and in a working directory, create two directories asus_icons_120x120 and asus_icons_130x130 containing the blank icon PNGs found elsewhere on this forum. Also put the transparent PNG for your own app in both of these directories at the appropriate sizes, named _norm.png. Then run this script passing the program name <app> and optionally a switch e.g. --large to make the 130x130 icons. The result is <group>_<app>_hi.png in one of the icon directories. In my case, I copy business_writerscafe_hi.png and writerscafe_norm.png to my distribution (categorised by icon size) and my Debian install script copies the appropriate ones to /opt/xandros/share/AsusLauncher.

#!/bin/sh
# Makes Eee PC icons from a PNG passed to the script.
# The PNG needs to be of the width and height equal to iconsize below,
# and needs to have an alpha channel. In PSP you can make an alpha channel
# with:
#
# 1) New Mask -> From Image (using Source Opacity)
# 2) Save to Alpha Channel
#
# The masked part of the image needs to be positioned towards the top to make
# room for the caption that will be added by the Eee PC.

imagemagickdir="c:/program files/imagemagick"
progname=
infile=
doaccessibility=1
dobusiness=1
dohome=1
dostudent=1

iconsize=120

make_icons()
{
    progname_hi=${progname}'_hi'

    # "$imagemagickdir/convert" $icondir/icon_background.png  -gravity Center $infile -composite $icondir/$progname_hi.png

    if [ "$doaccessibility" = "1" ]; then
        "$imagemagickdir/convert" $icondir/accessibility_icon_background.png -gravity Center $infile -composite $icondir/accessibility_$progname_hi.png
        echo "Made $icondir/accessibility_$progname_hi.png"
    fi

    if [ "$dobusiness" = "1" ]; then
        "$imagemagickdir/convert" $icondir/business_icon_background.png -gravity Center $infile -composite $icondir/business_$progname_hi.png
        echo "Made $icondir/business_$progname_hi.png"
    fi

    if [ "$dohome" = "1" ]; then
        "$imagemagickdir/convert" $icondir/home_icon_background.png  -gravity Center $infile -composite $icondir/home_$progname_hi.png
        echo "Made $icondir/home_$progname_hi.png"
    fi

    if [ "$dostudent" = "1" ]; then
        "$imagemagickdir/convert" $icondir/student_icon_background.png  -gravity Center $infile -composite $icondir/student_$progname_hi.png
        echo "Made $icondir/student_$progname_hi.png"
    fi
}

usage()
{
    echo "Makes Eee PC icons from a transparent PNG."
    echo "Pass the root of the icon name - <root>_norm.png should already exist."
    echo "Usage: $PROGNAME rootname [ options ]"
    echo Options:
    echo "    --help               Display this help message"
    echo "    --large              Use 130x130 icons instead of 120x120"
    echo "    --home               Make home icon only"
    echo "    --accessibility      Make accessibility icon only"
    echo "    --student            Make student icon only"
    echo "    --business           Make business icon only"
    exit 1
}

if [ "$1" = "" ]; then
  usage
  exit
fi

progname=$1

shift 1

# Process command line options.
for i in "$@"; do
    case "$i" in
    --large) iconsize=130 ;;
    --home) dohome=1 ; doaccessibility=0 ; dostudent=0 ; dobusiness=0 ;;
    --business) dohome=0 ; doaccessibility=0 ; dostudent=0 ; dobusiness=1 ;;
    --student) dohome=0 ; doaccessibility=0 ; dostudent=1 ; dobusiness=0 ;;
    --accessibility) dohome=0 ; doaccessibility=1 ; dostudent=0 ; dobusiness=0 ;;
    *)
        echo *** Unrecognised option $i.
        usage
        exit
        ;;
    esac
done

icondir=asus_icons_${iconsize}x${iconsize}
infile=$icondir/${progname}_norm.png

if [ ! -d ./$icondir ] ; then
    echo "Cannot find $icondir."
    exit
fi

if [ ! -f ./$infile ] ; then
    echo "Cannot find $infile."
    exit
fi

make_icons

echo Made ${iconsize}x${iconsize} images.

Phew! It seems a lot of trouble just to install an icon, but I don't see how else to cater for the different Eee PC environments in circulation.

Anyway, I now have a Debian package (built with wxWidgets using a desktop Debian Etch virtual machine) that will work on pretty much any Debian-based system, whether desktop or ultra-mobile. gOS systems and the Carphone Warehouse/Elonex Webbook use Debian packages too, but the latter uses a more-or-less standard Ubuntu distribution so the standard .desktop files and accompanying icons are all that are needed. I also distribute my app in RPM form, which should work on the SuSE-based MSI Wind.

(This article was adapted from a post on the Eee User forum at http://forum.eeeuser.com/viewtopic.php?id=40059.)