Jump to content
charlie-brise

Need help to combine different system commands

Recommended Posts

Hello,

I need help to combine three system commands: first "Quit all applications" - then "Empty trash" - then: "sleep".

I want to string them one after the next where the workflow quits applications, empties trash THEN sets itself to sleep.

Can anyone help me?

Cheers, Fritz

Share this post


Link to post

That functionality isn't currently possible in Alfred. The each of these system commands are considered a workflow "Action". You aren't able to string 3 "Actions" in a row. You could use a "Trigger" or "Input" item that would call all 3 but they would be called simultaneously. To accomplish this, I think your best bet would be to use a little AppleScript. Use the "Quit All Applications" action, then string a Output->Run Script item to the back end of that. In the Run Script, set the language to osascript and use that to "empty trash" and then simulate clicking the Sleep menu item

Share this post


Link to post

I found the answer I guess I was looking for here. I was wondering if you can string actions together and you can’t. What I wanted Alfred to do was empty my downloads folder and then empty the trash. Since David is right that in Alfred these run concurrently the downloads folder would be emptied. So i decided I’ll use my automator workflow but convert it to an app which Alfred sees. My automator workflow is the first part an Automator Workflow to move the finder items in the downloads folder to the trash and then another automator workflow that runs a simple Applescript to empty the trash. I created an Alfred workflow that would run applications from a keyword so I used the keyword em. Once that is invoked there’s my Automator workflow as an application and I hit enter and the folder is downloads folder is deleted and the trash emptied. I just wanted to try to do something in Alfred that I do elsewhere to get a feel for creating a workflow and it worked fine and fast. Since I invoke this from a Hotkey elsewhere I decided not to use a hotkey.

 

I would say the stringing of actions would be beneficial to the development of Alfred as I don’t know about in this case but you might be able to avoid Automator or Applescript if you could string actions. I’m guessing then that all boolean functions if you were to conduct this kind of workflow in Alfred would have to be handled outside of Alfred by either a program that supports boolean operation or Applescript or....????

 

Anyway, it works and it didn’t take me long to put together as this automator workflow I had already in my stock of Automator/Applescript workflows (the scripts I always find using a Google search - I don’t script LOL!).

Share this post


Link to post

I found the answer I guess I was looking for here. I was wondering if you can string actions together and you can’t. What I wanted Alfred to do was empty my downloads folder and then empty the trash. Since David is right that in Alfred these run concurrently the downloads folder would be emptied. So i decided I’ll use my automator workflow but convert it to an app which Alfred sees. My automator workflow is the first part an Automator Workflow to move the finder items in the downloads folder to the trash and then another automator workflow that runs a simple Applescript to empty the trash. I created an Alfred workflow that would run applications from a keyword so I used the keyword em. Once that is invoked there’s my Automator workflow as an application and I hit enter and the folder is downloads folder is deleted and the trash emptied. I just wanted to try to do something in Alfred that I do elsewhere to get a feel for creating a workflow and it worked fine and fast. Since I invoke this from a Hotkey elsewhere I decided not to use a hotkey.

 

I would say the stringing of actions would be beneficial to the development of Alfred as I don’t know about in this case but you might be able to avoid Automator or Applescript if you could string actions. I’m guessing then that all boolean functions if you were to conduct this kind of workflow in Alfred would have to be handled outside of Alfred by either a program that supports boolean operation or Applescript or....????

 

Anyway, it works and it didn’t take me long to put together as this automator workflow I had already in my stock of Automator/Applescript workflows (the scripts I always find using a Google search - I don’t script LOL!).

 

I'm not sure if something like this is on the cards or not but, not being able to string some together is simply the current implementation. Andrew has many ideas for improving and enhancing workflows in the future. Maybe that will be something included in a future release.

 

As for your example... Don't hold me to this (didn't test it) but, I think that emptying the downloads folder and then emptying the trash could be done with just a bash script, doing:

rm -rf ~/Downloads/*
rm -rf ~/.Trash/*

Which deletes everything in the Downloads folder and then deletes the contents of the hidden .Trash folder. 

Share this post


Link to post

I'm not sure if something like this is on the cards or not but, not being able to string some together is simply the current implementation. Andrew has many ideas for improving and enhancing workflows in the future. Maybe that will be something included in a future release.

 

As for your example... Don't hold me to this (didn't test it) but, I think that emptying the downloads folder and then emptying the trash could be done with just a bash script, doing:

rm -rf ~/Downloads/*
rm -rf ~/.Trash/*

Which deletes everything in the Downloads folder and then deletes the contents of the hidden .Trash folder. 

 

Thanks David. That would be even simpler in terms

Share this post


Link to post

Thanks David. That would be even simpler in terms

Hey David it works. Its slightly faster than my automator/Applescript workflow and a touch more transparent. You actually only need the first line and the downloads file is emptied. With the second command if there is a file sitting in the trash then it empties that. So both combined is what I want as I want the downloads and trash folder both emptied at the same time.

 

Thanks

 

Kerry

Share this post


Link to post

Hi David - I know nothing about this bash scripting thing but it is simple and its faster than the workflow that I use. Not by much but it is. The only thing about my workflow I like is that I get that trashing sound which I know means the files have been trashed. A little thing but I like it.

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