When an alert is interacted with, Alerter prints the result to stdout. You can capture this output in a shell script to drive logic based on user input.
Common return values include:
- The specific action name (e.g.,
YES, NO, MAYBE) @TIMEOUT: The alert was automatically closed due to the --timeout setting.@CLOSED: The user clicked the default close button.@CONTENTCLICKED: The user clicked the notification content.@ACTIONCLICKED: The user clicked the default action button.
Example Scripting Pattern:
ANSWER="$(./alerter --message 'Start now ?' --close-label No --actions 'YES,MAYBE,one more action' --timeout 10)"
case $ANSWER in
"@TIMEOUT") echo "Timeout man, sorry" ;;
"@CLOSED") echo "You clicked on the default alert' close button" ;;
"@CONTENTCLICKED") echo "You clicked the alert's content !" ;;
"@ACTIONCLICKED") echo "You clicked the alert default action button" ;;
"MAYBE") echo "Action MAYBE" ;;
"NO") echo "Action NO" ;;
"YES") echo "Action YES" ;;
**) echo "? --> $ANSWER" ;;
esac
ANSWER="$(./alerter --message 'Start now ?' --close-label No --actions 'YES,MAYBE,one more action' --timeout 10)"
case $ANSWER in
"@TIMEOUT") echo "Timeout man, sorry" ;;
"@CLOSED") echo "You clicked on the default alert' close button" ;;
"@CONTENTCLICKED") echo "You clicked the alert's content !" ;;
"@ACTIONCLICKED") echo "You clicked the alert default action button" ;;
"MAYBE") echo "Action MAYBE" ;;
"NO") echo "Action NO" ;;
"YES") echo "Action YES" ;;
**) echo "? --> $ANSWER" ;;
esac