Cross-desktop helpers
Hongli Lai
h.lai at chello.nl
Fri Dec 10 00:56:22 EET 2004
Alex Graveley wrote:
> * opening a web browser
It's a bit hacky, but I wrote a script which tries to guess the user's
preferred browser, based on the current desktop environment.
function detectDesktop() {
if [[ "$DISPLAY" = "" ]]; then
return 1
fi
local LC_ALL=C
local clients
if ! clients=`xlsclients`; then
# TODO: should we fall back to using ps?
return 1
fi
if echo "$clients" | grep -qE '(gnome-panel|nautilus|metacity)'; then
echo gnome
elif echo "$clients" | grep -qE '(kicker|slicker|karamba|kwin)'; then
echo kde
else
echo other
fi
return 1
}
desktop=`detectDesktop`
if [[ "$desktop" = "gnome" ]] && command -v gnome-open &>/dev/null; then
gnome-open "$1"
elif [[ "$desktop" = "kde" ]]; then
kfmclient exec "$1"
elif command -v firefox &>/dev/null; then
firefox "$1"
elif command -v mozilla &>/dev/null; then
mozilla "$1"
else
exit 1
fi
More information about the xdg
mailing list