diff --git a/cli/kdeconnect-cli.cpp b/cli/kdeconnect-cli.cpp index 1f4aa1402..8a968c19a 100644 --- a/cli/kdeconnect-cli.cpp +++ b/cli/kdeconnect-cli.cpp @@ -165,6 +165,9 @@ int main(int argc, char** argv) //Output id and description QTextStream(stdout) << id << '[' << description << ']' << endl; } + + //Exit with 1 if we didn't find a device + return int(!devices.isEmpty()); } else if(parser.isSet(QStringLiteral("refresh"))) { QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/modules/kdeconnect"), QStringLiteral("org.kde.kdeconnect.daemon"), QStringLiteral("forceOnNetworkChange")); blockOnReply(DBusHelper::sessionBus().asyncCall(msg)); diff --git a/cli/kdeconnect.zsh b/cli/kdeconnect.zsh index 9a45f15f8..ef76d218d 100644 --- a/cli/kdeconnect.zsh +++ b/cli/kdeconnect.zsh @@ -1,7 +1,13 @@ #compdef kdeconnect-cli _kdeconnect_device-ids() { - _values "KDE Connect device id" "${(f)$(kdeconnect-cli --shell-device-autocompletion=zsh 2>/dev/null)}" + local devices='' + devices="$(kdeconnect-cli --shell-device-autocompletion=zsh 2>/dev/null)" + if [[ $? -eq 0 ]]; then + _values "KDE Connect device id" "${(f)devices}" + else + _message -r "No KDE Connect devices reachable." + fi } #See http://zsh.sourceforge.net/Doc/Release/Completion-System.html#index-_005farguments for autocomplete documentation