Jump to content

Can Alfred trigger a workflow on a specific day and time?

Recommended Posts

54 minutes ago, Cullen said:

Will this operate on a timer?


Have a look for yourself:




Those are three of the time-related triggers: the top one (cron entry) gives you fine, precision control over when to run a macro (the equivalent in Keyboard Maestro of a workflow in Alfred), down to the times, which days of the week in which months and in which years, and absurd patterns like whenever the 14th of the month falls on a Sunday, or stuff like that (I currently have it set to 7PM daily); the second trigger there is the periodic trigger, that executes the macro at regular intervals on selected days; and the last one is simply a set time on selected days.

Other time-related ones (or system-event driven ones, really) allow you to trigger macros when the computer is simply idle (i.e. not being used); when the computer wakes up from sleep; or just before is goes to sleep.

Then there are triggers for when the wifi network changes, the audio output device changes, folder contents change, a USB device is inserted, a hotkey is pressed, etc.  The one main trigger is lacks is a good mouse trigger, for which Better Touch Tool is the go-to application for mouse-driven automation.

Regarding actions, Keyboard Maestro can interface with iTunes, interface with Chrome/Safari, press buttons or menu items of specific applications without needed them to be focussed, run scripts (Swift, JavaScript, AppleScript, shell), detect images on screen (pixel matching—some people find this useful for identifying objects to click on that don't have names, but I personally loathe any sort of automation that involves simulating keypresses or mouse clicks), manipulate windows, and a bunch of other stuff.  There's a good Wiki that explains all of the features in detail.

Given how your expectations for Alfred weren't met before you paid for it, I'd suggest this time doing in-depth research before you invest in buying Keyboard Maestro or any other software (a good rule of life, in general).  I believe KM has a trial period that allows you to use it for free so you can see if it does what you need.

Link to comment
  • 2 years later...
On 3/31/2017 at 12:40 AM, Sheldon said:

Could you point me to some AppleScript that show how to trigger a workflow using an external trigger?

Yes, I would be glad to.


Very late to this topic but now in those days before Christmas I left behind(!) my Samsung T5 SSD on the bus some 240 km from home and just HAD to schedule a crucial text message (SMS) to the driver a specific time to remind her to bring it back, which she had promised kindly enough. I learnt that crontab is deprecated and launchd recommended but the process led me anyway to make a simple Alfred workflow to make it easier to schedule cron jobs. And YES, you can write an AppleScript that calls an external trigger for Alfred which I just tested, like this:


`30 15 6 1 * osascript -e 'tell application id "com.runningwithcrayons.Alfred" to run trigger "myTrigger" in workflow "com.local.pdl" with argument "test"'`


In this case an Alfred workflow with the bundle com.local.pdl (just made up to test this) will run 30 minutes after 15 day 6 of month 1 (i.e. 6 Jan, 15:30). Here is a good tutorial on the Cron format.


Normally, you are recommended to go into Terminal and edit the crontab but I found it much easier to make a simple Alfred workflow for that with just a short keyword (‘c’) and a Run Script action (with AppleScript): `run script "~/Your path here/Crontab.scpt"` pointing to an AppleScript elsewhere (se below).


That script loads the current crontab and lets you “edit” it in an EXTREMELY SIMPLE dialog box. Nothing fancy, but really fast and helpful. (My original solution was actually to run an action (‘SMS’) in Drafts at the desired time, when I was in a meeting, and received a positive reply minutes later and my SSD back in the evening.) 😅



   set crontabs to do shell script "crontab -l"

on error

   set crontabs to ""

end try


display dialog "Quick crontab\n(Remember: for multiline, \\%)" with title "Cron jobs" default answer crontabs


-- Use newline instead of return as separator.

set crontabs to (paragraphs of (text returned of the result))

set AppleScript's text item delimiters to linefeed

set crontabs to crontabs as text


set AppleScript's text item delimiters to ""


if crontabs = "" then

   set cmd to "crontab -r"


   set cmd to "echo " & quoted form of crontabs & " | crontab"

end if


do shell script cmd


Also, Alfred’s Snippets come in handy. E.g. in order to insert more complicated jobs that may be hard to remember, just make sure you have a working job and save it as snippet. This one will run 10 am, every Friday (day 5 of the week)—BUT—will only continue with the actual osascript IF and only IF it is the last Friday of the month (because otherwise 7 days from now will return the same month in the date function).


`0 10 * * 5 [[ $(date +\%m) != $(date -v+7d +\%m) ]] && osascript -e 'display dialog "Last " & (word 1 of ((current date) as text)) & "this month."'`



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...