[Portland] Detect xdg-utils

Jeremy White jwhite at codeweavers.com
Tue Dec 26 14:58:10 PST 2006


> If you're still reading this, I will now get to the point :o) Is there
> already a proper way to test for xdg-utils ?

Well, the way we imagined it was that you would ship a copy of xdg-utils
with your product, but place the scripts at the end of the path.

That way, you could be certain that some version of xdg-utils would
be found, but you could go on to use the one preferred by the user
or distro if it was available.

However, I believe that all (nearly all?) of the scripts respect
a '--version' parameter, which if you pass, they will output something like this:
  <script-name> <script-version>
and return 0.  So you could fairly easily do something like this (in bash, anyways):

  ver_string=`xdg-open --version 2>/dev/null`
  if [ $? -eq 0 ] ; then
     # I have xdg-open
     echo $ver_string | read script_name script_ver
     if [ $script_ver == "1.0.1" ] ; then
         echo Oh, man, this version sucks, special case logic...
     else
         echo regular case, goodie...
         . . .
     fi
  else
     echo No xdg-open.  Mommy?!?!?!!?
  fi


Cheers,

Jeremy


More information about the Portland mailing list