Fix shell scripts to also find qdbus-qt5

parent eb63cf30
......@@ -8,25 +8,35 @@ shift
PERCENTAGE=$1
# special handling for qdbus variants
_qdbus=qdbus-qt5
if ! [ "$(which $_qdbus 2> /dev/null)" ]; then
_qdbus=qdbus
if ! [ "$(which $_qdbus 2> /dev/null)" ]; then
echo "Error: The qdbus (or qdbus-qt5) utility is missing."
exit 1
fi
fi
if [ ! $TARGET ]
then
qdbus org.kde.konversation /irc error "Can't write into status view."
$_qdbus org.kde.konversation /irc error "Can't write into status view."
else
if [ ! $PERCENTAGE ]
then
qdbus org.kde.konversation /irc error "USAGE: $0 <percentage>"
$_qdbus org.kde.konversation /irc error "USAGE: $0 <percentage>"
else
PERCENTAGE=`echo $PERCENTAGE | sed 's/^0\+//'`
LEFT=$(($PERCENTAGE/5))
RIGHT=$((20-$LEFT))
if [[ $PERCENTAGE -lt 0 ]]; then
qdbus org.kde.konversation /irc error "Percentage has to be bigger than 0"
$_qdbus org.kde.konversation /irc error "Percentage has to be bigger than 0"
exit
fi
if [[ $PERCENTAGE -gt 100 ]]; then
qdbus org.kde.konversation /irc error "Percentage has to be smaller than 100"
$_qdbus org.kde.konversation /irc error "Percentage has to be smaller than 100"
exit
fi
......@@ -64,6 +74,6 @@ else
OUTPUT="$OUTPUT *ding*"
fi
qdbus org.kde.konversation /irc say $SERVER "$TARGET" "Beer load $OUTPUT"
$_qdbus org.kde.konversation /irc say $SERVER "$TARGET" "Beer load $OUTPUT"
fi
fi
......@@ -11,22 +11,32 @@ TARGET=$2
export URL="$3"
NICK="$4"
# special handling for qdbus variants
_qdbus=qdbus-qt5
if ! [ "$(which $_qdbus 2> /dev/null)" ]; then
_qdbus=qdbus
if ! [ "$(which $_qdbus 2> /dev/null)" ]; then
echo "Error: The qdbus (or qdbus-qt5) utility is missing."
exit 1
fi
fi
if test ! -z $URL; then
if test $(which curl); then
TINYURL="$(curl -s -i https://tinyurl.com/api-create.php?url=$URL|tail -1)"
else
TINYURL="$(wget -T10 -t2 -qO- https://tinyurl.com/api-create.php?url=$URL|tail -1)"
fi
else qdbus org.kde.konversation /irc error "No url given: usage is \"/tinyurl URL [NickName]\""
else $_qdbus org.kde.konversation /irc error "No url given: usage is \"/tinyurl URL [NickName]\""
exit 1
fi
if test -z $TINYURL; then
qdbus org.kde.konversation /irc error "Unable run tinyurl script, please make sure you have curl or wget installed"
$_qdbus org.kde.konversation /irc error "Unable run tinyurl script, please make sure you have curl or wget installed"
else
if test ! -z $NICK; then
qdbus org.kde.konversation /irc say $SERVER "$TARGET" "${NICK}: $TINYURL"
$_qdbus org.kde.konversation /irc say $SERVER "$TARGET" "${NICK}: $TINYURL"
else
qdbus org.kde.konversation /irc say $SERVER "$TARGET" "$TINYURL"
$_qdbus org.kde.konversation /irc say $SERVER "$TARGET" "$TINYURL"
fi
fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment