如何使用 bash 确定声卡类型?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/517522/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I determine sound card type with bash?
提问by Scottie T
In bash, how do I determine what sound card is installed? I'm trying to create a plugin for Rhythmbox, and I'd like to test for this in a configuration script.
在 bash 中,如何确定安装了什么声卡?我正在尝试为 Rhythmbox 创建一个插件,我想在配置脚本中对此进行测试。
Edit:On my machine, I needed to use sudoto be able to use lspciand lsmod. @Quassnoi's answer using catworked without extra privileges.
编辑:在我的机器上,我需要使用sudo才能使用lspci和lsmod。@ Quassnoi的回答使用cat无需额外权限即可工作。
回答by Sean Bright
lspci | grep -i audio
回答by Quassnoi
cat /proc/asound/cards
回答by eduffy
I image you have a list of known sounds you'll be checking for in your configure script. So you can use grep and lsmod to check which one is loaded.
我想象你有一个已知声音的列表,你将在配置脚本中检查。所以你可以使用 grep 和 lsmod 来检查加载了哪个。
# lsmod | grep -q snd_hda_intel
# lsmod | grep -q snd_hda_intel
# echo $?
# echo $?
0
0
# lsmod | grep -q snd_foo
# lsmod | grep -q snd_foo
# echo $?
# echo $?
1
1

