Jump to content

[SOLVED] Launch apps as sudo? Possible?


Recommended Posts

Hi,

 

I’d LOVE an option in Alfred to launch apps as admin (=with sudo). For example, some file managers like Forklift or Marta don’t run as admin by default, making them less than ideal for my needs. 

 

I know I can do this in terninal, but I’d love to be able to do this in Alfred, preferably with modifier key (i.e. "hold Opt to run as admin“).

 

Any tips? Thanks!

Link to comment
15 hours ago, Stooovie said:

For example, some file managers like Forklift or Marta don’t run as admin by default

 

I find that weird, and that seems like a bad decision.

 

It also seems unlikely that option will ever be added to Alfred. Very few people would want it, and it gives users an easy way to shoot themselves in the foot.

 

15 hours ago, Stooovie said:

I know I can do this in terninal

 

You don’t need a terminal, you just need a Run Script Action.

Link to comment

Thanks! Just one thing - how do I pass my root (admin) password so I don’t have to enter it manually upon invoking the command? TY

 

EDIT: I’m just using the Terminal command action to do this, with a simple "sudo -b /Applications/Marta.app/Contents/MacOS/Marta" 

Link to comment
2 minutes ago, Stooovie said:

how do I pass my root (admin) password

 

You don't because that would be very bad from a security perspective.

 

Either you use AppleScript: do shell script "/Applications/Marta.app/Contents/MacOS/Marta" with administrator privileges


Or you edit your sudoers configuration, so you don't need to enter your password to use sudo.


The former is a better idea, security-wise.

Link to comment
  • vitor changed the title to [SOLVED] Launch apps as sudo? Possible?
  • 3 years later...

Old thread but useful information.

 

You can configure askpass

 

and then use sudo -A to automatically get the password from askpass

 

If you want to automatically use your login password, without having to enter it:

 

/usr/local/bin/askpass

 

#!/bin/sh
security find-generic-password -a yourusernamegoeshere -s login -w

 

Edited by gingerbeardman
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...