Merge pull request #711 from mrossinek/dunstctl-toggle-pause
Allow toggling pause state via dunstctl
This commit is contained in:
commit
fb2ffd425e
@ -872,8 +872,8 @@ Example time: "1000ms" "10m"
|
|||||||
|
|
||||||
=head1 MISCELLANEOUS
|
=head1 MISCELLANEOUS
|
||||||
|
|
||||||
Dunst can be paused via the `dunstctl set-running false` command. To unpause dunst use
|
Dunst can be paused via the `dunstctl set-paused true` command. To unpause dunst use
|
||||||
`dunstctl set-status true` and to unpause `dunstctl set-status false`.
|
`dunstctl set-paused false`.
|
||||||
Alternatively you can send SIGUSR1 and SIGUSR2 to pause and unpause
|
Alternatively you can send SIGUSR1 and SIGUSR2 to pause and unpause
|
||||||
respectively. For Example:
|
respectively. For Example:
|
||||||
|
|
||||||
|
@ -35,15 +35,15 @@ Redisplay the notification that was most recently closed. This can be called
|
|||||||
multiple times to show older notifications, up to the history limit configured
|
multiple times to show older notifications, up to the history limit configured
|
||||||
in dunst.
|
in dunst.
|
||||||
|
|
||||||
=item B<running>
|
=item B<is-paused>
|
||||||
|
|
||||||
Check if dunst is currently running or paused. If dunst is paused notifications
|
Check if dunst is currently running or paused. If dunst is paused notifications
|
||||||
will be kept but not shown until it is unpaused.
|
will be kept but not shown until it is unpaused.
|
||||||
|
|
||||||
=item B<set-running> true/false
|
=item B<set-paused> true/false/toggle
|
||||||
|
|
||||||
Set the paused status of dunst. If true, dunst is running normally, if false,
|
Set the paused status of dunst. If false, dunst is running normally, if true,
|
||||||
dunst is paused. See the running command and the dunst man page for more
|
dunst is paused. See the is-paused command and the dunst man page for more
|
||||||
information.
|
information.
|
||||||
|
|
||||||
=item B<debug>
|
=item B<debug>
|
||||||
|
45
dunstctl
45
dunstctl
@ -14,17 +14,17 @@ show_help() {
|
|||||||
cat <<-EOH
|
cat <<-EOH
|
||||||
Usage: dunstctl <command> [parameters]"
|
Usage: dunstctl <command> [parameters]"
|
||||||
Commands:
|
Commands:
|
||||||
action Perform the default action, or open the
|
action Perform the default action, or open the
|
||||||
context menu of the notification at the
|
context menu of the notification at the
|
||||||
given position
|
given position
|
||||||
close Close the last notification
|
close Close the last notification
|
||||||
close-all Close the all notifications
|
close-all Close the all notifications
|
||||||
context Open context menu
|
context Open context menu
|
||||||
history-pop Pop one notification from history
|
history-pop Pop one notification from history
|
||||||
running Check if dunst is running or paused
|
is-paused Check if dunst is running or paused
|
||||||
set-running [true|false] Set the pause status
|
set-paused [true|false|toggle] Set the pause status
|
||||||
debug Print debugging information
|
debug Print debugging information
|
||||||
help Show this help
|
help Show this help
|
||||||
EOH
|
EOH
|
||||||
}
|
}
|
||||||
dbus_send_checked() {
|
dbus_send_checked() {
|
||||||
@ -64,15 +64,24 @@ case "${1:-}" in
|
|||||||
"history-pop")
|
"history-pop")
|
||||||
method_call "${DBUS_IFAC_DUNST}.NotificationShow" >/dev/null
|
method_call "${DBUS_IFAC_DUNST}.NotificationShow" >/dev/null
|
||||||
;;
|
;;
|
||||||
"running")
|
"is-paused")
|
||||||
property_get running | ( read -r _ _ paused; printf "%s\n" "${paused}"; )
|
property_get paused | ( read -r _ _ paused; printf "%s\n" "${paused}"; )
|
||||||
;;
|
;;
|
||||||
"set-running")
|
"set-paused")
|
||||||
[ "${2:-}" ] \
|
[ "${2:-}" ] \
|
||||||
|| die "No status parameter specified. Please give either 'true' or 'false' as running parameter."
|
|| die "No status parameter specified. Please give either 'true', 'false' or 'toggle' as paused parameter."
|
||||||
[ "${2}" = "true" ] || [ "${2}" = "false" ] \
|
[ "${2}" = "true" ] || [ "${2}" = "false" ] || [ "${2}" = "toggle" ] \
|
||||||
|| die "Please give either 'true' or 'false' as running parameter."
|
|| die "Please give either 'true', 'false' or 'toggle' as paused parameter."
|
||||||
property_set running variant:boolean:"${2}"
|
if [ "${2}" = "toggle" ]; then
|
||||||
|
paused=$(property_get paused | ( read -r _ _ paused; printf "%s\n" "${paused}"; ))
|
||||||
|
if [ "${paused}" = "true" ]; then
|
||||||
|
property_set paused variant:boolean:false
|
||||||
|
else
|
||||||
|
property_set paused variant:boolean:true
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
property_set paused variant:boolean:"$2"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
"help"|"--help"|"-h")
|
"help"|"--help"|"-h")
|
||||||
show_help
|
show_help
|
||||||
|
10
src/dbus.c
10
src/dbus.c
@ -81,7 +81,7 @@ static const char *introspection_xml =
|
|||||||
" <method name=\"NotificationShow\" />"
|
" <method name=\"NotificationShow\" />"
|
||||||
" <method name=\"Ping\" />"
|
" <method name=\"Ping\" />"
|
||||||
|
|
||||||
" <property name=\"running\" type=\"b\" access=\"readwrite\">"
|
" <property name=\"paused\" type=\"b\" access=\"readwrite\">"
|
||||||
" <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"true\"/>"
|
" <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"true\"/>"
|
||||||
" </property>"
|
" </property>"
|
||||||
|
|
||||||
@ -588,8 +588,8 @@ GVariant *dbus_cb_dunst_Properties_Get(GDBusConnection *connection,
|
|||||||
{
|
{
|
||||||
struct dunst_status status = dunst_status_get();
|
struct dunst_status status = dunst_status_get();
|
||||||
|
|
||||||
if (STR_EQ(property_name, "running")) {
|
if (STR_EQ(property_name, "paused")) {
|
||||||
return g_variant_new_boolean(status.running);
|
return g_variant_new_boolean(!status.running);
|
||||||
} else {
|
} else {
|
||||||
LOG_W("Unknown property!\n");
|
LOG_W("Unknown property!\n");
|
||||||
*error = g_error_new(G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_PROPERTY, "Unknown property");
|
*error = g_error_new(G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_PROPERTY, "Unknown property");
|
||||||
@ -606,8 +606,8 @@ gboolean dbus_cb_dunst_Properties_Set(GDBusConnection *connection,
|
|||||||
GError **error,
|
GError **error,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
if (STR_EQ(property_name, "running")) {
|
if (STR_EQ(property_name, "paused")) {
|
||||||
dunst_status(S_RUNNING, g_variant_get_boolean(value));
|
dunst_status(S_RUNNING, !g_variant_get_boolean(value));
|
||||||
wake_up();
|
wake_up();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user