diff --git a/dunstctl b/dunstctl
index 2e1f7db..bce3028 100755
--- a/dunstctl
+++ b/dunstctl
@@ -20,6 +20,7 @@ function show_help() {
history-pop Pop one notification from history
status Check if
status-set [true|false] Set the status
+ debug Print debugging information
help Show this help
EOH
}
@@ -66,6 +67,21 @@ case "${1:-}" in
"help"|"--help"|"-h")
show_help
;;
+ "debug")
+ dbus-send --print-reply=literal --dest="${DBUS_NAME}" "${DBUS_PATH}" "${DBUS_IFAC_FDN}.GetServerInformation" >/dev/null 2>/dev/null \
+ || die "Dunst is not running."
+
+ dbus-send --print-reply=literal --dest="${DBUS_NAME}" "${DBUS_PATH}" "${DBUS_IFAC_FDN}.GetServerInformation" \
+ | (
+ read name vendor version protocol_version
+ [ "${name}" == dunst ]
+ printf "dunst version: %s\n" "${version}"
+ ) \
+ || die "Another notification manager is running. It's not dunst"
+
+ dbus-send --print-reply=literal --dest="${DBUS_NAME}" "${DBUS_PATH}" "${DBUS_IFAC_DUNST}.Ping" >/dev/null 2>/dev/null \
+ || die "Dunst controlling interface not available. Is the version too old?"
+ ;;
"")
die "dunstctl: No command specified. Please consult the usage."
;;
diff --git a/src/dbus.c b/src/dbus.c
index 0f8f93a..d554bcc 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -76,6 +76,7 @@ static const char *introspection_xml =
" "
" "
" "
+ " "
" "
" "
@@ -154,11 +155,13 @@ DBUS_METHOD(dunst_ContextMenuCall);
DBUS_METHOD(dunst_NotificationCloseAll);
DBUS_METHOD(dunst_NotificationCloseLast);
DBUS_METHOD(dunst_NotificationShow);
+DBUS_METHOD(dunst_Ping);
static struct dbus_method methods_dunst[] = {
{"ContextMenuCall", dbus_cb_dunst_ContextMenuCall},
{"NotificationCloseAll", dbus_cb_dunst_NotificationCloseAll},
{"NotificationCloseLast", dbus_cb_dunst_NotificationCloseLast},
{"NotificationShow", dbus_cb_dunst_NotificationShow},
+ {"Ping", dbus_cb_dunst_Ping},
};
void dbus_cb_dunst_methods(GDBusConnection *connection,
@@ -241,6 +244,17 @@ static void dbus_cb_dunst_NotificationShow(GDBusConnection *connection,
g_dbus_connection_flush(connection, NULL, NULL, NULL);
}
+/* Just a simple Ping command to give the ability to dunstctl to test for the existence of this interface
+ * Any other way requires parsing the XML of the Introspection or other foo. Just calling the Ping on an old dunst version will fail. */
+static void dbus_cb_dunst_Ping(GDBusConnection *connection,
+ const gchar *sender,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation)
+{
+ g_dbus_method_invocation_return_value(invocation, NULL);
+ g_dbus_connection_flush(connection, NULL, NULL, NULL);
+}
+
static void dbus_cb_GetCapabilities(
GDBusConnection *connection,