Thursday, April 25, 2024
 Popular · Latest · Hot · Upcoming
10
rated 0 times [  10] [ 0]  / answers: 1 / hits: 10550  / 3 Years ago, fri, july 2, 2021, 11:37:20

I've changed my ctrl-alt-l shortcut so instead of just locking the screen, the system goes into suspend.



(for reference, the command is gksudo pm-suspend-hybrid)



as you can see, the program needs to be run as root, so I added the gksudo. I'd really like to get the system to suspend without having to enter the password. Is there any way I can do this?


More From » suspend

 Answers
4

Open up a terminal and execute sudo visudo.



Then you can edit the sudoers file where you can specify who can execute which command as root with and without password. At the end of the file you paste either this line



nonprivilegeduser ALL=NOPASSWD:/usr/sbin/pm-suspend-hybrid


for every user to be able to execute that command as root without password, or



Your_Username ALL=NOPASSWD:/usr/sbin/pm-suspend-hybrid


for only your user to be able to do this (of course you have to adjust it for your user). Then you save the file (should be Ctrl+O) and exit the program (Ctrl+X).



At last, you have to edit your command to read sudo pm-suspend-hybrid instead of gksudo pm-suspend-hybrid.



NOTE: There should also be the possibility to do this with dbus (doesn't require sudoers editing) but this solution has the advantage that it works with every UI.


[#38470] Saturday, July 3, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
unsmmoth

Total Points: 72
Total Questions: 113
Total Answers: 95

Location: Thailand
Member since Tue, Oct 6, 2020
4 Years ago
;