dunstctl: Print help message on dbus communication failure
This commit is contained in:
parent
b1f64b266b
commit
936dbb039c
17
dunstctl
17
dunstctl
@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -eu
|
set -u
|
||||||
|
|
||||||
DBUS_NAME="org.freedesktop.Notifications"
|
DBUS_NAME="org.freedesktop.Notifications"
|
||||||
DBUS_PATH="/org/freedesktop/Notifications"
|
DBUS_PATH="/org/freedesktop/Notifications"
|
||||||
@ -24,17 +24,26 @@ show_help() {
|
|||||||
help Show this help
|
help Show this help
|
||||||
EOH
|
EOH
|
||||||
}
|
}
|
||||||
|
dbus_send_checked() {
|
||||||
|
dbus-send "$@"
|
||||||
|
rc="$?"
|
||||||
|
if [ "$rc" -eq "1" ]; then
|
||||||
|
echo "Failed to communicate with dunst, is it running? Or maybe the version is outdated." >&2
|
||||||
|
echo "Hint: You can try 'dunstctl debug' as a next debugging step." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
method_call() {
|
method_call() {
|
||||||
dbus-send --print-reply=literal --dest="${DBUS_NAME}" "${DBUS_PATH}" "$@"
|
dbus_send_checked --print-reply=literal --dest="${DBUS_NAME}" "${DBUS_PATH}" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
property_get() {
|
property_get() {
|
||||||
dbus-send --print-reply=literal --dest="${DBUS_NAME}" "${DBUS_PATH}" "${DBUS_IFAC_PROP}.Get" "string:${DBUS_IFAC_DUNST}" "string:${1}"
|
dbus_send_checked --print-reply=literal --dest="${DBUS_NAME}" "${DBUS_PATH}" "${DBUS_IFAC_PROP}.Get" "string:${DBUS_IFAC_DUNST}" "string:${1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
property_set() {
|
property_set() {
|
||||||
dbus-send --print-reply=literal --dest="${DBUS_NAME}" "${DBUS_PATH}" "${DBUS_IFAC_PROP}.Set" "string:${DBUS_IFAC_DUNST}" "string:${1}" "${2}"
|
dbus_send_checked --print-reply=literal --dest="${DBUS_NAME}" "${DBUS_PATH}" "${DBUS_IFAC_PROP}.Set" "string:${DBUS_IFAC_DUNST}" "string:${1}" "${2}"
|
||||||
}
|
}
|
||||||
|
|
||||||
command -v dbus-send >/dev/null 2>/dev/null || \
|
command -v dbus-send >/dev/null 2>/dev/null || \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user