Merge pull request #793 from ritze/get-number-of-notifications
Get the number of notifications
This commit is contained in:
		
						commit
						167d7dd7c3
					
				| @ -29,6 +29,11 @@ Close all notifications currently being displayed | |||||||
| Open the context menu, presenting all available actions and urls for the | Open the context menu, presenting all available actions and urls for the | ||||||
| currently open notifications. | currently open notifications. | ||||||
| 
 | 
 | ||||||
|  | =item B<count> [displayed/history/waiting] | ||||||
|  | 
 | ||||||
|  | Returns the number of displayed, shown and waiting notifications. If no argument | ||||||
|  | is provided, everything will be printed. | ||||||
|  | 
 | ||||||
| =item B<history-pop> | =item B<history-pop> | ||||||
| 
 | 
 | ||||||
| Redisplay the notification that was most recently closed. This can be called | Redisplay the notification that was most recently closed. This can be called | ||||||
|  | |||||||
							
								
								
									
										12
									
								
								dunstctl
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								dunstctl
									
									
									
									
									
								
							| @ -20,6 +20,7 @@ show_help() { | |||||||
| 	  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 | ||||||
|  | 	  count [displayed|history|waiting] Show the number of notifications | ||||||
| 	  history-pop                       Pop one notification from history | 	  history-pop                       Pop one notification from history | ||||||
| 	  is-paused                         Check if dunst is running or paused | 	  is-paused                         Check if dunst is running or paused | ||||||
| 	  set-paused [true|false|toggle]    Set the pause status | 	  set-paused [true|false|toggle]    Set the pause status | ||||||
| @ -61,6 +62,17 @@ case "${1:-}" in | |||||||
| 	"context") | 	"context") | ||||||
| 		method_call "${DBUS_IFAC_DUNST}.ContextMenuCall" >/dev/null | 		method_call "${DBUS_IFAC_DUNST}.ContextMenuCall" >/dev/null | ||||||
| 		;; | 		;; | ||||||
|  | 	"count") | ||||||
|  | 		[ $# -eq 1 ] || [ "${2}" = "displayed" ] || [ "${2}" = "history" ] || [ "${2}" = "waiting" ] \ | ||||||
|  | 			|| die "Please give either 'displayed', 'history', 'waiting' or none as count parameter." | ||||||
|  | 		if [ $# -eq 1 ]; then | ||||||
|  | 			property_get waitingLength   | ( read -r _ _ waiting;   printf "              Waiting: %s\n" "${waiting}" ) | ||||||
|  | 			property_get displayedLength | ( read -r _ _ displayed; printf "  Currently displayed: %s\n" "${displayed}" ) | ||||||
|  | 			property_get historyLength   | ( read -r _ _ history;   printf "              History: %s\n" "${history}") | ||||||
|  | 		else | ||||||
|  | 			property_get ${2}Length | ( read -r _ _ notifications; printf "%s\n" "${notifications}"; ) | ||||||
|  | 		fi | ||||||
|  | 		;; | ||||||
| 	"history-pop") | 	"history-pop") | ||||||
| 		method_call "${DBUS_IFAC_DUNST}.NotificationShow" >/dev/null | 		method_call "${DBUS_IFAC_DUNST}.NotificationShow" >/dev/null | ||||||
| 		;; | 		;; | ||||||
|  | |||||||
							
								
								
									
										13
									
								
								src/dbus.c
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								src/dbus.c
									
									
									
									
									
								
							| @ -85,6 +85,10 @@ static const char *introspection_xml = | |||||||
|     "            <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"true\"/>" |     "            <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"true\"/>" | ||||||
|     "        </property>" |     "        </property>" | ||||||
| 
 | 
 | ||||||
|  |     "        <property name=\"displayedLength\" type=\"u\" access=\"read\" />" | ||||||
|  |     "        <property name=\"historyLength\" type=\"u\" access=\"read\" />" | ||||||
|  |     "        <property name=\"waitingLength\" type=\"u\" access=\"read\" />" | ||||||
|  | 
 | ||||||
|     "    </interface>" |     "    </interface>" | ||||||
|     "</node>"; |     "</node>"; | ||||||
| 
 | 
 | ||||||
| @ -597,6 +601,15 @@ GVariant *dbus_cb_dunst_Properties_Get(GDBusConnection *connection, | |||||||
| 
 | 
 | ||||||
|         if (STR_EQ(property_name, "paused")) { |         if (STR_EQ(property_name, "paused")) { | ||||||
|                 return g_variant_new_boolean(!status.running); |                 return g_variant_new_boolean(!status.running); | ||||||
|  |         } else if (STR_EQ(property_name, "displayedLength")) { | ||||||
|  |                 unsigned int displayed = queues_length_displayed(); | ||||||
|  |                 return g_variant_new_uint32(displayed); | ||||||
|  |         } else if (STR_EQ(property_name, "historyLength")) { | ||||||
|  |                 unsigned int history =  queues_length_history(); | ||||||
|  |                 return g_variant_new_uint32(history); | ||||||
|  |         } else if (STR_EQ(property_name, "waitingLength")) { | ||||||
|  |                 unsigned int waiting =  queues_length_waiting(); | ||||||
|  |                 return g_variant_new_uint32(waiting); | ||||||
|         } 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"); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Nikos Tsipinakis
						Nikos Tsipinakis