You are not logged in.

#1 2021-11-14 15:07:06

FreddyMalone
Member
Registered: 2021-09-18
Posts: 6

Play a soundfile each time it asks for sudo password

Is there a possible way to play a specific soundfile of my liking each time it asks for sudo password to enter? So far I have no clue how to do so but just know it has to be in a script of course.

Offline

#2 2021-11-14 15:13:31

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 25,912
Website

Re: Play a soundfile each time it asks for sudo password

Sudo has the flag -B for "bell" which will play a sound ... just not a soundfile of your choice.

Otherwise you could use the -A flag to specify your own password entry program which in turn could play the sound file and ask for a password.  However, if this is a script, make sure it is owned and only modifiable by the root user.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2021-11-14 15:33:32

FreddyMalone
Member
Registered: 2021-09-18
Posts: 6

Re: Play a soundfile each time it asks for sudo password

just tested

sudo -B rm -f test

a slight bell tone when System Volume is set to 120% and soundcard to 200% lol


will it help if I create an alias for sudo? like

alias sudo='mplayer sudosound.ogg'

will play the sound and at the same time doing the sudo task.

Offline

#4 2021-11-14 15:53:28

seth
Member
Registered: 2012-09-03
Posts: 25,134

Re: Play a soundfile each time it asks for sudo password

No, it'll play a soundfile instead of actually running sudo and it will do so unconditionally - whether you've to issue a password or not.
Most TEs allow you to configure the bell (soundfile, beep, volume, colorflash, …) so you might look into that.

Edit:

printf '\a'

will play the bell as well (for testing your TE settings)

Last edited by seth (2021-11-14 15:54:14)

Offline

#5 2021-11-14 16:03:14

FreddyMalone
Member
Registered: 2021-09-18
Posts: 6

Re: Play a soundfile each time it asks for sudo password

seth wrote:

TE

as of Terminal Environment?
I use Guake and can only see 1 box regarding to sound which is under General for "Play system alert sound on bell".

under Hooks I can see an empty box that leads by "on Show:" for "In this dialog you can attach your own command or script to various Guake events". Is this the right direction I am looking at?

Last edited by FreddyMalone (2021-11-14 16:10:28)

Offline

#6 2021-11-14 16:14:48

seth
Member
Registered: 2012-09-03
Posts: 25,134

Re: Play a soundfile each time it asks for sudo password

"terminal emulator" - the options seems to allow you to play the alert from your sound scheme (which you can configure in your desktop environment settings, likely gnome?)

Edit: you'll have to try or wait for somebody to show up who uses guake - I'm navigating this by google image search ;-)

Last edited by seth (2021-11-14 16:16:00)

Offline

#7 2021-11-14 16:15:01

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 25,912
Website

Re: Play a soundfile each time it asks for sudo password

TE = Terminal Emulator, but yes, guake is one of these.  I'm not familiar with guake, but if it allows you to customize how it responds to the terminal "bell", that would actually be the ideal way for you to achieve your end goal, and the "guake events" sounds like the promising direction to continue down.

Note that even a proper alias for sudo would not really achieve your goals as it'd play the sound every time sudo was called even if no password was required.  And it could fail for any script that either calls /bin/sudo directly or otherwise doesn't inherit the alias (i.e., makepkg's calls to sudo might not use the alias).


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#8 2021-11-14 16:52:02

FreddyMalone
Member
Registered: 2021-09-18
Posts: 6

Re: Play a soundfile each time it asks for sudo password

alias sudo='mplayer /home/user/Music/sudosound.ogg; sudo'

how about this? to me, it looks good but haven't tested it yet. Want to read from you before I 'hear' it lol

Offline

#9 2021-11-14 17:14:05

Slithery
Forum Moderator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 4,755

Re: Play a soundfile each time it asks for sudo password

Read Trilby's second paragraph.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#10 2021-11-14 17:42:20

FreddyMalone
Member
Registered: 2021-09-18
Posts: 6

Re: Play a soundfile each time it asks for sudo password

Slithery wrote:

Read Trilby's second paragraph.

I've overseen it, thanks for the reminder.

Offline

Board footer

Powered by FluxBB