Jump to content

Notification from a workflow


Recommended Posts

I've created a simple workflow using a script to switch the audio output on my Mac from Stereo to Mono or back. I'd like a notification to tell me what it's just done. I've got a keyword, a Run NSAppleScript and a Post Notification block

 

The AppleScript is as follows,

on alfred_script(q)
  tell application "System Preferences"
	reveal anchor "Hearing" of pane id "com.apple.preference.universalaccess"
end tell
tell application "System Events"
	tell application process "System Preferences"
		tell window "Accessibility"
			set monoStereoCheckbox to checkbox 2 of group 1
			if (get value of monoStereoCheckbox) as boolean is true then
				set statusNow to xmlItem({title:“Stereo”})
			else
				set statusNow to xmlItem({title:“Mono”})
			end if
			tell monoStereoCheckbox to click
		end tell
	end tell
end tell
if application "System Preferences" is running then
	tell application "System Preferences" to quit
end if
return giveFeedback(statusNow)
end alfred_script

and the Post Notification has a Title and {query} in the text...I'm assuming I'm missing something simple and obvious but what?

Link to comment

I've created a simple workflow using a script to switch the audio output on my Mac from Stereo to Mono or back. I'd like a notification to tell me what it's just done. I've got a keyword, a Run NSAppleScript and a Post Notification block

 

The AppleScript is as follows,

on alfred_script(q)
  tell application "System Preferences"
	reveal anchor "Hearing" of pane id "com.apple.preference.universalaccess"
end tell
tell application "System Events"
	tell application process "System Preferences"
		tell window "Accessibility"
			set monoStereoCheckbox to checkbox 2 of group 1
			if (get value of monoStereoCheckbox) as boolean is true then
				set statusNow to xmlItem({title:“Stereo”})
			else
				set statusNow to xmlItem({title:“Mono”})
			end if
			tell monoStereoCheckbox to click
		end tell
	end tell
end tell
if application "System Preferences" is running then
	tell application "System Preferences" to quit
end if
return giveFeedback(statusNow)
end alfred_script

and the Post Notification has a Title and {query} in the text...I'm assuming I'm missing something simple and obvious but what?

 

Is "return giveFeedback(statusNow)" where you are trying to return the status back to a notification? If so, what is giveFeedback? Where is it defined? Also, I think I saw an article last night where you can easily create a notification directly from AppleScript here. Shouldn't need that though. Just shared for information purposes. Lets get it working from Alfred :)

Link to comment

erm, giveFeedback probably isn't defined because i was looking at other scripts and trying things out to see what worked...in this case it didn't :-)

 

I guess I just need to know what needs to be output from the script for it to be picked up in the {query} section of the notification box

Edited by jodrell
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...