我想在用sudo执行的bash脚本中杀死pulseaudio。 问题是命令" pulseaudio -k" root用户无法使用。 我决定将脚本中的用户切换到实际启动了pulseaudio服务器的非特权用户。
#!/bin/bash
su -c "pulseaudio -k" user_name
如果我将所有内容放在bash文件中并执行它,
sudo ./kill-pulseaudio.sh
我收到错误:
E: [pulseaudio] core-util.c: XDG_RUNTIME_DIR (/run/user/1000) is not
owned by us (uid 0), but by uid 1000! (This could e g happen if you
try to connect to a non-root PulseAudio as a root user, over the
native protocol. Don't do that.)
E: [pulseaudio] main.c: Failed to kill daemon: No such file or directory
但如果我只是从终端调用以下命令,则没有错误:
[user_name@host ~]$ su -c "pulseaudio -k" user_name
我做错了什么?