Dr.Peril Posted November 30, 2021 Share Posted November 30, 2021 Hey all, I'm wondering if it's possible to trigger Alfred via SSH? I would like to trigger the Ejectall feature from shortcuts on my iPhone with the "Run script over SSH" function. I've found some terminal commands to eject all disks like: find /Volumes -maxdepth 1 -not -user root -print0 | xargs -0 diskutil eject but it chokes if /Volumes has a network share attached... :S Thanks for the help! Link to comment
deanishe Posted November 30, 2021 Share Posted November 30, 2021 You could try passing the ejectall query to Alfred and simulating ↩ via AppleScript. Using GUI apps from the command-line is a last resort kind of thing, though. You'd be better off writing a script based on your above commands. Link to comment
Dr.Peril Posted November 30, 2021 Author Share Posted November 30, 2021 Hey, thanks for idea, I'll see if it's possible. Yeah, I have an apple script the shortcut runs if it's being run on my Mac, I guess I was just hoping there was a CLI option that would make life a bit easier. Sounds like it might actually be more doing. Link to comment
deanishe Posted November 30, 2021 Share Posted November 30, 2021 41 minutes ago, Dr.Peril said: I guess I was just hoping there was a CLI option that would make life a bit easier. That’s diskutil, tbh. You can enumerate volumes in AppleScript quite easily, too. Link to comment
Dr.Peril Posted December 2, 2021 Author Share Posted December 2, 2021 (edited) So just by chance this was just posted on SIx Colors: https://sixcolors.com/post/2021/12/run-shortcuts-from-the-mac-command-line/ Basically, you can call shortcuts in the command line. So Alfred isn't really needed, one can run the shortcut directly via ssh. Edited December 2, 2021 by Dr.Peril Link to comment
deanishe Posted December 2, 2021 Share Posted December 2, 2021 5 hours ago, Dr.Peril said: one can run the shortcut directly via ssh. Sure, but what shortcut? I thought you wanted to eject volumes? Link to comment
Dr.Peril Posted December 2, 2021 Author Share Posted December 2, 2021 (edited) Oh, apologies, yeah there are a ton of Eject Disk shortcuts, I grabbed some Apple Script as mentioned and put it into a shortcut. Just wanted to 'post a solution' ¯\_(ツ)_/¯ I guess that makes this entire thread kinda moot since I didn't land on using Alfred but... maybe someone else will find this useful: -- Copy of script b/c editing on iPhone sometimes nulls that block. to ejectAllDisk() try tell application "Finder" -- Prevent unmounting full disks, those generally are mounted backup snapshots etc. eject (every disk whose ejectable is true and free space is not equal to 0) end tell on error display notification "Failed to eject all disks" with title "Eject all disks" subtitle "Failure" end try end ejectAllDisk -- this is the entry method. on run try with timeout of 30 seconds ejectAllDisk() end timeout on error display notification "Eject is still in progress" with title "Eject all disks" subtitle "Timeout" ejectAllDisk() end try end run Edited December 2, 2021 by Dr.Peril 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