2006-12-20 18:14:39 +01:00
|
|
|
#! /bin/bash
|
|
|
|
|
|
|
|
# If possible use the KDE program kdialog
|
|
|
|
# otherwise fall back to the generic X program xmessage.
|
2009-07-04 10:52:15 +02:00
|
|
|
# The "..." quotation when calling 'test -x' is crucial
|
|
|
|
# because calling 'test -x' without explicite empty argument
|
|
|
|
# (when 'type -p kdialog' fails) would result true.
|
|
|
|
if test -x "$( type -p kdialog )"
|
2006-12-20 18:14:39 +01:00
|
|
|
then PopupProgram='kdialog --error'
|
|
|
|
else PopupProgram='xmessage'
|
|
|
|
fi
|
|
|
|
|
|
|
|
# If hp-toolbox cannot access a hplip device
|
|
|
|
# then it doesn't show up on the X window system.
|
|
|
|
# It only shows an 'ERROR...' or 'error...' message on stderr
|
|
|
|
# but exits nevertheless with zero exit code.
|
|
|
|
# Note that one cannot grep for '^error' because there are leading
|
|
|
|
# escape codes (e.g. "esc [ 3 1 ; 0 1 m") in the output lines.
|
2009-07-04 10:52:15 +02:00
|
|
|
# The "..." quotation when calling 'test -x' is crucial
|
|
|
|
# because calling 'test -x' without explicite empty argument
|
|
|
|
# (when 'type -p hp-toolbox' fails) would result true.
|
|
|
|
if test -x "$( type -p hp-toolbox )"
|
2006-12-20 18:14:39 +01:00
|
|
|
then hp-toolbox 2>&1 1>/dev/null | grep -q -i 'error' && $PopupProgram 'No HP all-in-one device found (those devices require a special setup).'
|
|
|
|
else $PopupProgram 'Cannot execute hp-toolbox.'
|
|
|
|
fi
|
|
|
|
|