politicus Posted December 30, 2017 Share Posted December 30, 2017 The "Force quit applications" is a nice OS X built-in application. The great thing is you can select more than one application at the same time. I would like to be able to use Alfred and its "quit" and "force quit" commands to quit more than one application at the same time. In other words, selecting more than one application just like I can select more than one file/folder with the "buffer" feature. One could use the same modifiers keys of the buffer feature. In practice: 1°) I open Alfred search bar, 2°) I type "quit", 3°) I select all the applications I want to quit with the modifier key (for example: Alt+Up arrow), 4°) I hit Alt+Right arrow, then hit Enter, 5°) The selected applications close. Link to comment
deanishe Posted December 30, 2017 Share Posted December 30, 2017 You can add applications to Alfred's File Buffer, so all you need to do is implement a File Action that accepts applications and kills them. There's really no need for a native Alfred feature. Link to comment
politicus Posted December 31, 2017 Author Share Posted December 31, 2017 Yes you are absolutely right. But I do not know how to create an action that would kill the applications I added to the buffer. Here is my workflow: https://www.dropbox.com/s/ki9s2clkhteerjt/Force_Quit.alfredworkflow?dl=0 Link to comment
deanishe Posted December 31, 2017 Share Posted December 31, 2017 That's a very low effort attempt. You haven't even added the File Action I told you you needed. Here's a script that will kill the applications passed to it. Put it in a Run Script with Language = /usr/bin/osascript (JS) I'll leave you to figure out the File Action for yourself. // Extract name of application from path var appRegex = new RegExp('.+/([^/]+)\\.app$', 'i') var sys = Application('System Events') // Return application name based on path passed in by Alfred function getAppName(path) { var match = appRegex.exec(path) return match[1] } // Check the name we guessed is the right one function validateApp(path, name) { var procs = sys.processes.whose({name: name}) for (var i = 0; i < procs.length; i++) { var proc = procs[i] if (proc.applicationFile().posixPath() == path) { return true } } return false } // Kill running applications function run(argv) { argv.forEach(function(path) { var name = getAppName(path) if (!Application(name).running()) { console.log(`${name} is not running`) return } if (validateApp(path, name)) { console.log(`killing ${name} ...`) var app = Application.currentApplication() app.includeStandardAdditions = true app.doShellScript(`killall -SIGKILL "${name}"`) } else { console.log(`guessed the wrong name for ${path} :(`) } }) } Link to comment
deanishe Posted December 31, 2017 Share Posted December 31, 2017 I'm going to move this thread to the "Workflow Help & Questions" forum. Link to comment
politicus Posted January 6, 2018 Author Share Posted January 6, 2018 You are right it is a low effort attempt. I can explain you why. I tried to create a workflow in the middle of the night while having a cold and a neighbour partying like crazy. The party was so loud I didn't understand what I was reading on my computer... I am not looking for excuses. Just explaining the context I also want to add it is Thank you for the script. Link to comment
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