On 12/09/12 17:58, David Crisp wrote:
#!/bin/sh b=`ps ax | grep '\(firefox\|chrome\|opera\)' | grep -v grep | head -1 | awk '{print $5}'` if [ -n $b ] exec $b "$@" else exec firefox "$@" fi
Aside from the missing "then": if [ -n $b ] ; then .. it seems to work well, thanks! Next silly question: How do I set the default action on opening a URL? In Ubuntu the "correct" approach is to goto System Settings -> System -> Details -> Default Applications but this only lists the apps installed as alternatives in /var/lib/dpkg/alternatives/x-www-browser. I'm not sure that editing that file is a Good Thing [tm]... TBH most of my problem is opening links in emails, and as I use Thunderbird that can be set in TB's settings (and seems to work well). It has got me thinking though that the update-alternatives concept, good as it is, could be improved by checking to see if one of the "alternatives" is already open and re-using it first rather than starting the default alternative. It wouldn't be as simple as just having a symlink to the chosen default but could just be a symlink to a script that worked out the alternatives as per David's script above. I think this needs a bit more thought/work... Thanks again, though; the simple script above is already pretty close to what I need. Mark -- Mark Rogers // More Solutions Ltd (Peterborough Office) // 0844 251 1450 Registered in England (0456 0902) 21 Drakes Mews, Milton Keynes, MK8 0ER