Joshua Shew Posted November 19 Posted November 19 This isn't really a "I have a specific problem" sort of question, but more of a broad inquiry. Is is possible to design a workflow to perform actions in the background, even when not prompted by the user? I'm working on my Archive Page workflow and I'd like it to be able to remember URLs that failed to get snapshotted, and retry them again (and again) at a set time. I just don't know where to start with this. Presumably you would have to set up some sort of script that executes automatically? I don't have any experience with this, so pointers would be appreciated. Here's what I've found so far: Alfred Cron: Execute Scripts (and workflows) on Intervals [v1.1] from 2014. Not working anymore, and not exactly what I was looking for. Gallery workflows tagged "learning". None of these implement a feature like this. vitor basically saying "don't do this" in 2013 (if I'm understanding correctly)
vitor Posted November 19 Posted November 19 I wasn’t exactly saying “don’t do it”, but more specifically “I don’t think Alfred should do it natively”. You can do it via launchd, by setting up an agent and telling it to call an External Trigger. I do that in the 1Password and Google Drive workflows. launchd.info is a great website to learn about how the system works and LaunchControl is a GUI app to build those¹. However, I still don’t think you should do it. It is a powerful system that works reliably if you understand the rules and constraints but is also tough to get your head around correctly². I am extremely careful with the agents I build and even implement failsafes for them to auto-uninstall when the workflow is no longer installed/active to not linger in the user’s machine. They also require an immense amount of trust. Not only are users notified by macOS whenever one of those agents is installed³, security tools sometimes flag them even when they’re innocuous⁴. In the workflows where I implement such a system, they always have a simple way to turn it off in the Workflow’s Configuration. Plus, it’s always done as the very last resort and I remove that functionality from workflows whenever I can (which I did in Pin Plus and AppleScript Dictionaries). The functionality is only added when absolutely necessary for the proper functioning of the workflow, and the agents are set up to run as little as possible. In the Archive Page workflow, you’d have an agent that would be running periodically and most of the time not doing anything. In the instances where it would, it would be contacting an external service and possibly degrading it⁵. It could also make the Internet Archive block users in regular browsing by seeing too many or repeated requests (if there’s a bug, it could be even worse). Speaking from experience on automating submitting links to the Internet Archive, it is definitely not something that is too reliable or that should be done unattended. I have been looking at the progress you’ve made with the workflow and think it could make a nice addition to the Alfred Gallery when it’s been stable for a bit, but having such a periodic running script would give me pause for all of the above⁶. I would recommend you instead save the failed links to a file in alfred_workflow_data or alfred_workflow_cache, and on each new save check if the file exists, and if so try to save the ones from the list as well. Or have a Script Filter Input read that file and show the failures, so people can choose to retry from there at their leisure. Hope everything was clear and helpful! ¹ I can’t attest to the app’s functionality, as I always build by hand. ² And if you make a mistake, it’s laborious and hard to fix it for the people who installed it before the fix. ³ Which is a good thing. Though macOS then craps the bed by not being clear in the GUI what is active. ⁴ Because bad actors sometimes use that system for persistence. ⁵ As you might know, the Internet Archive was recently victim of a cyber attack. Being hammered with automated requests from several people would not have been good. ⁶ Though of course you would always be able to share it on your own website, GitHub, etc. That doesn’t change. Joshua Shew 1
Joshua Shew Posted November 19 Author Posted November 19 @vitor thank you so much for making such a detailed response. I can imagine it must have taken a while to put together all those references. I may take a look at the links you provided for my own purposes, but I will take your advice and avoid integrating them into Archive Page. 26 minutes ago, vitor said: I would recommend you instead save the failed links to a file in alfred_workflow_data or alfred_workflow_cache, and on each new save check if the file exists, and if so try to save the ones from the list as well. Or have a Script Filter Input read that file and show the failures, so people can choose to retry from there at their leisure. Now this sounds exciting to me. I haven't had the chance to really explore the power of the Script Filter, but I think this would be a good excuse to give it a try. Thank you again for your time and advice! vitor 1
Joshua Shew Posted November 19 Author Posted November 19 On different note, I'm not sure what the criteria is for topics getting marked as "solved" on this forum, but I can say that my initial question (and much more) have been "solved" at this point.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now