grml-info: improve checks for present browsers
[grml-scripts.git] / usr_bin / grml-info
index 86b9904..391ca6e 100755 (executable)
@@ -4,34 +4,62 @@
 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2.
-# Latest change: Fre Jul 07 22:42:18 CEST 2006 [mika]
 ################################################################################
 
 local PAGE='/usr/share/doc/grml-docs/startpage.html'
 
+. /etc/grml/script-functions
+
 # do we have X?
-if ! [ -n "$DISPLAY" ]; then
- # is it grml-small?
- if grep -q small /etc/grml_version ; then
-    links $PAGE
- else
-  # do we have a real console?
-  if [[ $(tty) == /dev/tty* ]] ; then
-    # do we have framebuffer support?
-    if [ -c /dev/fb0 ] ; then
-      links2 -driver fb $PAGE
-    else
-      # no, we don't have framebuffer
-      w3m $PAGE
-    fi
-  # no, probably we are running inside GNU screen
-  else
-    w3m $PAGE
-  fi
- fi
-# oh, we have X!
-else
-  dillo $PAGE
+if [ -n "$DISPLAY" ]; then
+   if check4progs dillo ; then
+      dillo $PAGE
+   elif check4progs firefox ; then
+      firefox $PAGE
+   elif check4progs x-www-browser ; then
+      x-www-browser $PAGE
+   elif check4progs Xdialog ; then
+      Xdialog --msgbox "Sorry, no usable X browser found." 0 0
+   fi
+else # no X:
+   # do we have a real console?
+   if [[ $(tty) == /dev/tty* ]] ; then
+      # do we have framebuffer support?
+      if [ -c /dev/fb0 ] ; then
+         if check4progs links2 ; then
+            links2 -driver fb $PAGE
+         elif check4progs w3m ; then
+            w3m $PAGE
+         elif check4progs links ; then
+            links $PAGE
+         else
+            echo "Sorry, neither links2 nor w3m nor links available. Exiting.">&2
+            exit 20
+         fi
+      else # no, we don't have framebuffer
+         if check4progs w3m ; then
+            w3m $PAGE
+         elif check4progs links ; then
+            links $PAGE
+         elif check4progs links2 ; then
+            links2 $PAGE
+         else
+            echo "Sorry, neither w3m nor links nor links2 available. Exiting.">&2
+            exit 30
+         fi
+      fi
+   else # no, probably we are running inside GNU screen
+      if check4progs w3m ; then
+         w3m $PAGE
+      elif check4progs links2 ; then
+         links2 $PAGE
+      elif check4progs links ; then
+         links $PAGE
+      else
+         echo "Sorry, neither w3m nor links2 nor links available. Exiting.">&2
+         exit 40
+      fi
+   fi
 fi
 
 ## END OF FILE #################################################################