You are not logged in.

#1 2019-12-26 21:16:27

Maniaxx
Member
Registered: 2014-05-14
Posts: 761

How to beep on 'sudo' password requests?

Hallo,
when i use e.g. trizen to compile an aur package or update the system there might be coming several sudo password requests during the process (actually 'sudo pacman'). Sometimes i do not notice them as they were running in the background and thus time out. How can i make these password requests give more feedback like an pcspkr beep for example? Is there something for the 'sudoers' file maybe? I neither want to swap the 'sudo' binary with a script (for security reasons) nor do i want to run trizen as root.

Last edited by Maniaxx (2019-12-26 21:18:31)


sys2064

Offline

#2 2019-12-26 21:54:08

frostschutz
Member
Registered: 2013-11-15
Posts: 1,652

Re: How to beep on 'sudo' password requests?

sudo has the --beep option but there doesn't seem to be a way to make this always-on in the sudo configuration files

otherwise you could try to set up an askpass helper that beeps (or does anything else really)

you could also make an independent service that polls for waiting sudo processes and beeps ( while sleep 5; pidof sudo && beep; done )

Offline

#3 2019-12-26 21:56:29

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,731

Re: How to beep on 'sudo' password requests?

Alter the promt and have it include '\a' - you can use "man sudoers" or "man sudo" (there's an environment)
You could also alias sudo to sth. like "beep; sudo" or whatever (eg. using notify-send)

Offline

#4 2019-12-26 22:06:42

frostschutz
Member
Registered: 2013-11-15
Posts: 1,652

Re: How to beep on 'sudo' password requests?

nice, I missed the SUDO_PROMPT. That should be the best option.

$ export SUDO_PROMPT=$'\a'"[sudo] password for %p: "
$ sudo ...

that's assuming your terminal actually beeps when it encounters \a

Offline

#5 2019-12-27 20:35:29

Maniaxx
Member
Registered: 2014-05-14
Posts: 761

Re: How to beep on 'sudo' password requests?

Thanks, that's working great. There is even something already for the sudoers file in the wiki.

Any ideas for visual feedback? Blinking terminal in taskbar, notification or something (xfce, gnome-terminal)?

Last edited by Maniaxx (2019-12-27 20:35:46)


sys2064

Offline

#6 2019-12-27 20:55:23

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,731

Re: How to beep on 'sudo' password requests?

https://bugzilla.gnome.org/show_bug.cgi?id=557593 and I would be "surprised" if the sudo prompt could execute random commands
:-(

On the upside, maybe you can gain interest in a better TE smile

Offline

#7 2019-12-27 22:06:23

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,517
Website

Re: How to beep on 'sudo' password requests?

Then start acting surprised.

$ export SUDO_PROMPT="$(ls /)[sudo] password for %p: "
$ sudo pacman -Syu
boot/
dev/
etc/
home/
lost+found/
mnt/
opt/
proc/
root/
run/
srv/
sys/
tmp/
usr/
var/
bin@
lib@
lib64@
sbin@[sudo] password for jmcclure:

"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#8 2019-12-27 22:31:17

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,731

Re: How to beep on 'sudo' password requests?

I can't reason why, but this feels wrong (or bad)
However you can then oc. use xdotool or wmctrl to activate the window (and have the WM set it urgent if it's not supposed to get the focus right now)

Offline

#9 2019-12-27 23:35:28

frostschutz
Member
Registered: 2013-11-15
Posts: 1,652

Re: How to beep on 'sudo' password requests?

@Trilby: that executes the command at the time of setting the variable, not at the time of calling sudo ...?

Offline

#10 2019-12-27 23:54:07

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,517
Website

Re: How to beep on 'sudo' password requests?

Hmm, yes, it seems you are right.  Sorry ... nevermind my last post.

PS1 is evaluated at each prompt - so one can put such things there, but SUDO_PROMPT doesn't seem to be.

Last edited by Trilby (2019-12-28 00:04:43)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB