Jump to content
WalterBeiter

start applescript, display notification with Alfred, continue applescript

Recommended Posts

I want to use Alfred notification for displaying data that I got using AppleScript. So the workflow basically gathers an information using an AppleScript, returns that information back to Alfred wich should display a notification and then the AppleScript should continue or another AppleScript should start, which should get the variables of the first AppleScript. 

The reason for this is that I cannot figure out how to use custom icons in notifications within AppleScript. I wanted to use Alfred for this, since I can configure notifications how I want. So the goal is to return information from an AppleScript back to Alfred, Alfred is displaying those information and continues the AppleScript. Is this possible?

Share this post


Link to post

Hello @WalterBeiter,

 

We can’t properly help you without access to your Workflow.


Debugging can already be hard with access to the code, and you’re asking us to guess yours from a description. There are multiple places where you code or Workflow setup may be going wrong. Without looking at it we’re shooting in the dark, which is a waste of time for everyone involved (including you).


Read the Reporting Problems with Workflows topic, as it gives a nice overview on how to build an effective report.

 


 

6 minutes ago, WalterBeiter said:

The reason for this is that I cannot figure out how to use custom icons in notifications within AppleScript.

 

You can’t from an AppleScript script — a notification with a custom icon needs to come from an app. Take a look at notificator (disclaimer: I’m the author) for a quick way to make such apps. I use it in my own Workflows.

 

8 minutes ago, WalterBeiter said:

So the goal is to return information from an AppleScript back to Alfred, Alfred is displaying those information and continues the AppleScript. Is this possible?

 

Yes. The simplest way is to not have it in succession. There’s no apparent reason why the next step would need to come only after the notification has fired. Instead, make two connections:

7G3bSU9.png

Share this post


Link to post
29 minutes ago, vitor said:

We can’t properly help you without access to your Workflow.

→ The workflow does not exist yet, I am still developing the AppleScript but I ran into the problem of not knowing how to display custom notifications with a custom icon. So I though I would just do this using Alfreds notifications...

Sorry for not providing enough details. I thou they would distract from the main problem. 

 

 

Quote

You can’t from an AppleScript script — a notification with a custom icon needs to come from an app. Take a look at notificator (disclaimer: I’m the author) for a quick way to make such apps. I use it in my own Workflows.

→ notificator could work. I installed it, but it requires me to first run that setup, saving that app somewhere and then call it again. This would be a lot of file handling which is not that nice... Where do you store the icon, the app,.. etc.

Not quite sure how I would implement this into an AppleScript. I know I could launch notificator with the do shell script command, but how do I bundle the custom notificator app with the script? I want to use this with every Mac. 

 

 

Quote

Yes. The simplest way is to not have it in succession. There’s no apparent reason why the next step would need to come only after the notification has fired. Instead, make two connections:

7G3bSU9.png

→ this could work, but how to I return multiple variables in AppleScript and then importing them in the second AppleScript? And how do I post a notification of just one of them? 

And it would require dividing the applescript wherever I post a notification. 

 

Edit: How do I specify a custom icon in this notification? I can't find an area where I drag and drop an icon.

 

 

 

Bottom line: If this gets to complicated, I will just give up and stick with the script editor icon. 

Edited by WalterBeiter

Share this post


Link to post

Regarding notificator, you only run the setup once: to solidify an icon and a bundle ID. It’ll save it to an app. You keep that app inside the Workflow’s directory and call it as needed. It will work on all your Macs when you share/sync the Workflow amongst them.


You cannot set your own icon with Alfred’s notification; if you could, notificator would not exist. A notification needs to use the icon of the app that calls it.


If you want to return multiple variables, you’ll need to either return a JSON in the same format as the JSON Utility or you’ll do it like in other languages: returning everything in your own format and then parsing it yourself. I would recommend against AppleScript, though. Unless it’s absolutely necessary, doing complex tasks with it is more pain than it is worth.

Share this post


Link to post
31 minutes ago, vitor said:

Regarding notificator, you only run the setup once: to solidify an icon and a bundle ID. It’ll save it to an app. You keep that app inside the Workflow’s directory and call it as needed. It will work on all your Macs when you share/sync the Workflow amongst them.

→ maybe I'll try that. 

 

31 minutes ago, vitor said:

If you want to return multiple variables, you’ll need to either return a JSON in the same format as the JSON Utility or you’ll do it like in other languages: returning everything in your own format and then parsing it yourself. I would recommend against AppleScript, though. Unless it’s absolutely necessary, doing complex tasks with it is more pain than it is worth.

→ AppleScript is mandatory for what I'll try to accomplish, so I think I will try that notificator thing. If that does not work or get to complex, I will skip this part and use the standard icons. But having the script editor icon show up whatever notification is displayed is annoying, especially when scripting multiple applications. 

 

Thanks for all the quick help. 

Share this post


Link to post
2 hours ago, WalterBeiter said:

AppleScript is mandatory for what I'll try to accomplish

 

Are you sure you can't use JXA instead? JavaScript supports JSON.


If not, just because you have to use AppleScript for parts of your workflow, doesn't mean you have to use it for everything. Apart from a couple of loonies, who appear to actually like AppleScript, most workflow developers use the absolute minimum amount of AS, and do the rest in a sane language.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...