Change running to paused state on "server" side
This allows the boolean "inversion" to happen in the C code instead of post-processing in the dunstctl shell script.
This commit is contained in:
		
							parent
							
								
									2e301b1d39
								
							
						
					
					
						commit
						0dfcc1420d
					
				
							
								
								
									
										25
									
								
								dunstctl
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								dunstctl
									
									
									
									
									
								
							| @ -44,14 +44,6 @@ property_set() { | |||||||
| 	dbus_send_checked --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}" | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| invert_boolean() { |  | ||||||
| 	if [ "${1}" = "true" ]; then |  | ||||||
| 		printf "%s\n" "false" |  | ||||||
| 	elif [ "${1}" = "false" ]; then |  | ||||||
| 		printf "%s\n" "true" |  | ||||||
| 	fi |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| command -v dbus-send >/dev/null 2>/dev/null || \ | command -v dbus-send >/dev/null 2>/dev/null || \ | ||||||
| 	die "Command dbus-send not found" | 	die "Command dbus-send not found" | ||||||
| 
 | 
 | ||||||
| @ -73,10 +65,7 @@ case "${1:-}" in | |||||||
| 		method_call "${DBUS_IFAC_DUNST}.NotificationShow" >/dev/null | 		method_call "${DBUS_IFAC_DUNST}.NotificationShow" >/dev/null | ||||||
| 		;; | 		;; | ||||||
| 	"is-paused") | 	"is-paused") | ||||||
| 		running=$(property_get running | ( read -r _ _ running; printf "%s\n" "${running}"; )) | 		property_get paused | ( read -r _ _ paused; printf "%s\n" "${paused}"; ) | ||||||
| 		# invert boolean to indiciate pause status rather than running one |  | ||||||
| 		paused=$(invert_boolean "${running}") |  | ||||||
| 		printf "%s\n" "${paused}" |  | ||||||
| 		;; | 		;; | ||||||
| 	"set-paused") | 	"set-paused") | ||||||
| 		[ "${2:-}" ] \ | 		[ "${2:-}" ] \ | ||||||
| @ -84,16 +73,14 @@ case "${1:-}" in | |||||||
| 		[ "${2}" = "true" ] || [ "${2}" = "false" ] || [ "${2}" = "toggle" ] \ | 		[ "${2}" = "true" ] || [ "${2}" = "false" ] || [ "${2}" = "toggle" ] \ | ||||||
| 			|| die "Please give either 'true', 'false' or 'toggle' as paused parameter." | 			|| die "Please give either 'true', 'false' or 'toggle' as paused parameter." | ||||||
| 		if [ "${2}" = "toggle" ]; then | 		if [ "${2}" = "toggle" ]; then | ||||||
| 			running=$(property_get running | ( read -r _ _ running; printf "%s\n" "${running}"; )) | 			paused=$(property_get paused | ( read -r _ _ paused; printf "%s\n" "${paused}"; )) | ||||||
| 			if [ "${running}" = "true" ]; then | 			if [ "${paused}" = "true" ]; then | ||||||
| 				property_set running variant:boolean:false | 				property_set paused variant:boolean:false | ||||||
| 			else | 			else | ||||||
| 				property_set running variant:boolean:true | 				property_set paused variant:boolean:true | ||||||
| 			fi | 			fi | ||||||
| 		else | 		else | ||||||
| 			# invert boolean to indiciate running status rather than pause one | 			property_set paused variant:boolean:"$2" | ||||||
| 			running=$(invert_boolean "${2}") |  | ||||||
| 			property_set running variant:boolean:"${running}" |  | ||||||
| 		fi | 		fi | ||||||
| 		;; | 		;; | ||||||
| 	"help"|"--help"|"-h") | 	"help"|"--help"|"-h") | ||||||
|  | |||||||
| @ -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
	 mrossinek
						mrossinek