Re: beeps and other sounds
On Saturday, 19-10-2024 at 14:20 Greg Wooledge wrote:
> On Sat, Oct 19, 2024 at 13:58:56 +1100, George at Clug wrote:
> > When logged in as root, the following worked for me using a local user account (e.g. not the root user):
> >
> > # runuser --user notroot -- bash -lic 'aplay /usr/share/sounds/purple/alert.wav'
>
> Huh, interesting. That --user option is NOT in the man page. I'm
> guessing it's a synonym for -u. (I verified that it actually does
> work on Debian 12. It's just not documented.)
>
> The bash -lic '...' wrapper seems like overkill to me, though. You
> don't need a login shell (-l) or an interactive shell (-i) to run
> that aplay command.
>
> I also wonder whether runuser is actually needed there, or whether
> setpriv would be sufficient. It might depend on whether "notroot" is
> already logged in to establish a "seat" or whatever it's called with
> access to the audio devices. (That's another thing I'd want to test,
> if this were my project -- does "notroot" need to be logged in for
> this to work?)
>
I was curious too:
# runuser --user notloggedinnotrootuser -- bash -lic 'aplay /usr/share/sounds/sound-icons/prompt.wav'
aplay: main:831: audio open error: Host is down
I guess you have to be logged in as yourself, using your own user account, then open a terminal and su in as root.
My account is not in sudoers so I have not tested this using "sudo -i", or "sudo su".
And I found that this worked even without the -l and -i
# runuser --user loggedinnotrootuser -- bash -c 'aplay /usr/share/sounds/sound-icons/prompt.wav'
I was not able get "# sudo -u" to work in place of using runuser.
So much more testing one could do.
>
Reply to: