我已通过 HDMI 端口将电视连接到 PC。每次打开 PC 时,我都需要在 pavucontrol(在配置选项卡中)中将 (HDMI) 更改为 (HDMI 3)。我希望制作一个可以帮我更改它的 bash 脚本。
它在 pavucontrol 中的样子如下:
pacmd list_sinks
命令输出前和后pavucontrol 中的变化:
pacmd list_sinks
改变之前:
3 sink(s) available.
index: 0
name: <alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo>
driver: <module-alsa-card.c>
flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
state: IDLE
suspend cause:
priority: 9049
volume: front-left: 65886 / 101% / 0,14 dB, front-right: 65886 / 101% / 0,14 dB
balance 0,00
base volume: 65536 / 100% / 0,00 dB
volume steps: 65537
muted: no
current latency: 45,38 ms
max request: 6 KiB
max rewind: 344 KiB
monitor source: 0
sample spec: s16le 2 k 44100 Hz
channel map: front-left,front-right
Stereo
used by: 0
linked by: 1
configured latency: 40,00 ms; range is 0,50 .. 2000,00 ms
card: 0 <alsa_card.usb-C-Media_Electronics_Inc._USB_Audio_Device-00>
module: 6
properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "USB Audio"
alsa.id = "USB Audio"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "0"
alsa.card = "2"
alsa.card_name = "USB Audio Device"
alsa.long_card_name = "C-Media Electronics Inc. USB Audio Device at usb-0000:01:00.0-10, full speed"
alsa.driver_name = "snd_usb_audio"
device.bus_path = "pci-0000:01:00.0-usb-0:10:1.0"
sysfs.path = "/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-10/1-10:1.0/sound/card2"
udev.id = "usb-C-Media_Electronics_Inc._USB_Audio_Device-00"
device.bus = "usb"
device.vendor.id = "0d8c"
device.vendor.name = "C-Media Electronics, Inc."
device.product.id = "0012"
device.product.name = "USB Audio Device"
device.serial = "C-Media_Electronics_Inc._USB_Audio_Device"
device.string = "front:2"
device.buffering.buffer_size = "352800"
device.buffering.fragment_size = "176400"
device.access_mode = "mmap+timer"
device.profile.name = "analog-stereo"
device.profile.description = "Analogowe stereo"
device.description = "USB Audio Device Analogowe stereo"
alsa.mixer_name = "USB Mixer"
alsa.components = "USB0d8c:0012"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-usb"
ports:
analog-output-speaker: Głośniki (priority 10000, latency offset 0 usec, available: unknown)
properties:
device.icon_name = "audio-speakers"
active port: <analog-output-speaker>
* index: 2
name: <alsa_output.pci-0000_0a_00.3.analog-stereo>
driver: <module-alsa-card.c>
flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
state: IDLE
suspend cause:
priority: 9059
volume: front-left: 65536 / 100% / 0,00 dB, front-right: 65536 / 100% / 0,00 dB
balance 0,00
base volume: 65536 / 100% / 0,00 dB
volume steps: 65537
muted: no
current latency: 31,46 ms
max request: 6 KiB
max rewind: 64 KiB
monitor source: 3
sample spec: s16le 2 k 44100 Hz
channel map: front-left,front-right
Stereo
used by: 0
linked by: 1
configured latency: 40,00 ms; range is 0,50 .. 371,52 ms
card: 2 <alsa_card.pci-0000_0a_00.3>
module: 8
properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "ALC887-VD Analog"
alsa.id = "ALC887-VD Analog"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "0"
alsa.card = "1"
alsa.card_name = "HD-Audio Generic"
alsa.long_card_name = "HD-Audio Generic at 0xfd700000 irq 58"
alsa.driver_name = "snd_hda_intel"
device.bus_path = "pci-0000:0a:00.3"
sysfs.path = "/devices/pci0000:00/0000:00:08.1/0000:0a:00.3/sound/card1"
device.bus = "pci"
device.vendor.id = "1022"
device.vendor.name = "Advanced Micro Devices, Inc. [AMD]"
device.product.id = "1457"
device.string = "front:1"
device.buffering.buffer_size = "65536"
device.buffering.fragment_size = "32768"
device.access_mode = "mmap+timer"
device.profile.name = "analog-stereo"
device.profile.description = "Analogowe stereo"
device.description = "HD-Audio Generic Analogowe stereo"
alsa.mixer_name = "Realtek ALC887-VD"
alsa.components = "HDA:10ec0887,1458a182,00100302"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
ports:
analog-output-lineout: Wyjście liniowe (priority 9900, latency offset 0 usec, available: yes)
properties:
analog-output-headphones: Słuchawki (priority 9000, latency offset 0 usec, available: no)
properties:
device.icon_name = "audio-headphones"
active port: <analog-output-lineout>
index: 7
name: <alsa_output.pci-0000_08_00.1.hdmi-stereo>
driver: <module-alsa-card.c>
flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
state: IDLE
suspend cause:
priority: 9050
volume: front-left: 65536 / 100% / 0,00 dB, front-right: 65536 / 100% / 0,00 dB
balance 0,00
base volume: 65536 / 100% / 0,00 dB
volume steps: 65537
muted: no
current latency: 39,91 ms
max request: 6 KiB
max rewind: 64 KiB
monitor source: 8
sample spec: s16le 2 k 44100 Hz
channel map: front-left,front-right
Stereo
used by: 0
linked by: 1
configured latency: 40,00 ms; range is 0,50 .. 371,52 ms
card: 1 <alsa_card.pci-0000_08_00.1>
module: 7
properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "HDMI 0"
alsa.id = "HDMI 0"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "3"
alsa.card = "0"
alsa.card_name = "HDA NVidia"
alsa.long_card_name = "HDA NVidia at 0xfd080000 irq 56"
alsa.driver_name = "snd_hda_intel"
device.bus_path = "pci-0000:08:00.1"
sysfs.path = "/devices/pci0000:00/0000:00:03.1/0000:08:00.1/sound/card0"
device.bus = "pci"
device.vendor.id = "10de"
device.vendor.name = "NVIDIA Corporation"
device.product.id = "0fb9"
device.string = "hdmi:0"
device.buffering.buffer_size = "65536"
device.buffering.fragment_size = "32768"
device.access_mode = "mmap+timer"
device.profile.name = "hdmi-stereo"
device.profile.description = "Digital Stereo (HDMI)"
device.description = "HDA NVidia Digital Stereo (HDMI)"
alsa.mixer_name = "Nvidia GPU 80 HDMI/DP"
alsa.components = "HDA:10de0080,104385c7,00100100"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
ports:
hdmi-output-0: HDMI / DisplayPort (priority 5900, latency offset 0 usec, available: yes)
properties:
device.icon_name = "video-display"
device.product.name = "E2240
"
active port: <hdmi-output-0>
pacmd list_sinks
更改后:
3 sink(s) available.
index: 0
name: <alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo>
driver: <module-alsa-card.c>
flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
state: IDLE
suspend cause:
priority: 9049
volume: front-left: 65886 / 101% / 0,14 dB, front-right: 65886 / 101% / 0,14 dB
balance 0,00
base volume: 65536 / 100% / 0,00 dB
volume steps: 65537
muted: no
current latency: 45,35 ms
max request: 6 KiB
max rewind: 344 KiB
monitor source: 0
sample spec: s16le 2 k 44100 Hz
channel map: front-left,front-right
Stereo
used by: 0
linked by: 1
configured latency: 40,00 ms; range is 0,50 .. 2000,00 ms
card: 0 <alsa_card.usb-C-Media_Electronics_Inc._USB_Audio_Device-00>
module: 6
properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "USB Audio"
alsa.id = "USB Audio"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "0"
alsa.card = "2"
alsa.card_name = "USB Audio Device"
alsa.long_card_name = "C-Media Electronics Inc. USB Audio Device at usb-0000:01:00.0-10, full speed"
alsa.driver_name = "snd_usb_audio"
device.bus_path = "pci-0000:01:00.0-usb-0:10:1.0"
sysfs.path = "/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-10/1-10:1.0/sound/card2"
udev.id = "usb-C-Media_Electronics_Inc._USB_Audio_Device-00"
device.bus = "usb"
device.vendor.id = "0d8c"
device.vendor.name = "C-Media Electronics, Inc."
device.product.id = "0012"
device.product.name = "USB Audio Device"
device.serial = "C-Media_Electronics_Inc._USB_Audio_Device"
device.string = "front:2"
device.buffering.buffer_size = "352800"
device.buffering.fragment_size = "176400"
device.access_mode = "mmap+timer"
device.profile.name = "analog-stereo"
device.profile.description = "Analogowe stereo"
device.description = "USB Audio Device Analogowe stereo"
alsa.mixer_name = "USB Mixer"
alsa.components = "USB0d8c:0012"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-usb"
ports:
analog-output-speaker: Głośniki (priority 10000, latency offset 0 usec, available: unknown)
properties:
device.icon_name = "audio-speakers"
active port: <analog-output-speaker>
* index: 2
name: <alsa_output.pci-0000_0a_00.3.analog-stereo>
driver: <module-alsa-card.c>
flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
state: IDLE
suspend cause:
priority: 9059
volume: front-left: 65536 / 100% / 0,00 dB, front-right: 65536 / 100% / 0,00 dB
balance 0,00
base volume: 65536 / 100% / 0,00 dB
volume steps: 65537
muted: no
current latency: 38,88 ms
max request: 6 KiB
max rewind: 64 KiB
monitor source: 3
sample spec: s16le 2 k 44100 Hz
channel map: front-left,front-right
Stereo
used by: 0
linked by: 1
configured latency: 40,00 ms; range is 0,50 .. 371,52 ms
card: 2 <alsa_card.pci-0000_0a_00.3>
module: 8
properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "ALC887-VD Analog"
alsa.id = "ALC887-VD Analog"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "0"
alsa.card = "1"
alsa.card_name = "HD-Audio Generic"
alsa.long_card_name = "HD-Audio Generic at 0xfd700000 irq 58"
alsa.driver_name = "snd_hda_intel"
device.bus_path = "pci-0000:0a:00.3"
sysfs.path = "/devices/pci0000:00/0000:00:08.1/0000:0a:00.3/sound/card1"
device.bus = "pci"
device.vendor.id = "1022"
device.vendor.name = "Advanced Micro Devices, Inc. [AMD]"
device.product.id = "1457"
device.string = "front:1"
device.buffering.buffer_size = "65536"
device.buffering.fragment_size = "32768"
device.access_mode = "mmap+timer"
device.profile.name = "analog-stereo"
device.profile.description = "Analogowe stereo"
device.description = "HD-Audio Generic Analogowe stereo"
alsa.mixer_name = "Realtek ALC887-VD"
alsa.components = "HDA:10ec0887,1458a182,00100302"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
ports:
analog-output-lineout: Wyjście liniowe (priority 9900, latency offset 0 usec, available: yes)
properties:
analog-output-headphones: Słuchawki (priority 9000, latency offset 0 usec, available: no)
properties:
device.icon_name = "audio-headphones"
active port: <analog-output-lineout>
index: 6
name: <alsa_output.pci-0000_08_00.1.hdmi-stereo-extra2>
driver: <module-alsa-card.c>
flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
state: IDLE
suspend cause:
priority: 9050
volume: front-left: 65536 / 100% / 0,00 dB, front-right: 65536 / 100% / 0,00 dB
balance 0,00
base volume: 65536 / 100% / 0,00 dB
volume steps: 65537
muted: no
current latency: 30,36 ms
max request: 6 KiB
max rewind: 64 KiB
monitor source: 7
sample spec: s16le 2 k 44100 Hz
channel map: front-left,front-right
Stereo
used by: 0
linked by: 1
configured latency: 40,00 ms; range is 0,50 .. 371,52 ms
card: 1 <alsa_card.pci-0000_08_00.1>
module: 7
properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "HDMI 2"
alsa.id = "HDMI 2"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "8"
alsa.card = "0"
alsa.card_name = "HDA NVidia"
alsa.long_card_name = "HDA NVidia at 0xfd080000 irq 56"
alsa.driver_name = "snd_hda_intel"
device.bus_path = "pci-0000:08:00.1"
sysfs.path = "/devices/pci0000:00/0000:00:03.1/0000:08:00.1/sound/card0"
device.bus = "pci"
device.vendor.id = "10de"
device.vendor.name = "NVIDIA Corporation"
device.product.id = "0fb9"
device.string = "hdmi:0,2"
device.buffering.buffer_size = "65536"
device.buffering.fragment_size = "32768"
device.access_mode = "mmap+timer"
device.profile.name = "hdmi-stereo-extra2"
device.profile.description = "Digital Stereo (HDMI 3)"
device.description = "HDA NVidia Digital Stereo (HDMI 3)"
alsa.mixer_name = "Nvidia GPU 80 HDMI/DP"
alsa.components = "HDA:10de0080,104385c7,00100100"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
ports:
hdmi-output-2: HDMI / DisplayPort 3 (priority 5700, latency offset 0 usec, available: yes)
properties:
device.icon_name = "video-display"
device.product.name = "LG TV
"
active port: <hdmi-output-2>
pactl list cards
输出:
0. karta
Nazwa: alsa_card.usb-C-Media_Electronics_Inc._USB_Audio_Device-00
Sterownik: module-alsa-card.c
Właściciel modułu: 6
Właściwości:
alsa.card = "2"
alsa.card_name = "USB Audio Device"
alsa.long_card_name = "C-Media Electronics Inc. USB Audio Device at usb-0000:01:00.0-10, full speed"
alsa.driver_name = "snd_usb_audio"
device.bus_path = "pci-0000:01:00.0-usb-0:10:1.0"
sysfs.path = "/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-10/1-10:1.0/sound/card2"
udev.id = "usb-C-Media_Electronics_Inc._USB_Audio_Device-00"
device.bus = "usb"
device.vendor.id = "0d8c"
device.vendor.name = "C-Media Electronics, Inc."
device.product.id = "0012"
device.product.name = "USB Audio Device"
device.serial = "C-Media_Electronics_Inc._USB_Audio_Device"
device.string = "2"
device.description = "USB Audio Device"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-usb"
Profile:
input:analog-mono: Wejście Analogowe mono (odpływy: 0, źródła: 1, priorytet: 2, dostępne: tak)
output:analog-stereo: Wyjście Analogowe stereo (odpływy: 1, źródła: 0, priorytet: 6000, dostępne: tak)
output:analog-stereo+input:analog-mono: Wyjście Analogowe stereo + Wejście Analogowe mono (odpływy: 1, źródła: 1, priorytet: 6002, dostępne: tak)
output:iec958-stereo: Wyjście Cyfrowe stereo (IEC958) (odpływy: 1, źródła: 0, priorytet: 5500, dostępne: tak)
output:iec958-stereo+input:analog-mono: Wyjście Cyfrowe stereo (IEC958) + Wejście Analogowe mono (odpływy: 1, źródła: 1, priorytet: 5502, dostępne: tak)
off: Wyłączone (odpływy: 0, źródła: 0, priorytet: 0, dostępne: tak)
Aktywny profil: output:analog-stereo+input:analog-mono
Porty:
analog-input-mic: Mikrofon (priority: 8700, latency offset: 0 usec)
Właściwości:
device.icon_name = "audio-input-microphone"
Część profilu: input:analog-mono, output:analog-stereo+input:analog-mono, output:iec958-stereo+input:analog-mono
analog-output-speaker: Głośniki (priority: 10000, latency offset: 0 usec)
Właściwości:
device.icon_name = "audio-speakers"
Część profilu: output:analog-stereo, output:analog-stereo+input:analog-mono
iec958-stereo-output: Wyjście cyfrowe (S/PDIF) (priority: 0, latency offset: 0 usec)
Część profilu: output:iec958-stereo, output:iec958-stereo+input:analog-mono
1. karta
Nazwa: alsa_card.pci-0000_08_00.1
Sterownik: module-alsa-card.c
Właściciel modułu: 7
Właściwości:
alsa.card = "0"
alsa.card_name = "HDA NVidia"
alsa.long_card_name = "HDA NVidia at 0xfd080000 irq 56"
alsa.driver_name = "snd_hda_intel"
device.bus_path = "pci-0000:08:00.1"
sysfs.path = "/devices/pci0000:00/0000:00:03.1/0000:08:00.1/sound/card0"
device.bus = "pci"
device.vendor.id = "10de"
device.vendor.name = "NVIDIA Corporation"
device.product.id = "0fb9"
device.string = "0"
device.description = "HDA NVidia"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
Profile:
output:hdmi-stereo: Wyjście Digital Stereo (HDMI) (odpływy: 1, źródła: 0, priorytet: 5400, dostępne: tak)
output:hdmi-stereo-extra1: Wyjście Digital Stereo (HDMI 2) (odpływy: 1, źródła: 0, priorytet: 5200, dostępne: tak)
output:hdmi-surround-extra1: Wyjście Digital Surround 5.1 (HDMI 2) (odpływy: 1, źródła: 0, priorytet: 100, dostępne: tak)
output:hdmi-surround71-extra1: Wyjście Digital Surround 7.1 (HDMI 2) (odpływy: 1, źródła: 0, priorytet: 100, dostępne: tak)
output:hdmi-stereo-extra2: Wyjście Digital Stereo (HDMI 3) (odpływy: 1, źródła: 0, priorytet: 5200, dostępne: tak)
output:hdmi-surround-extra2: Wyjście Digital Surround 5.1 (HDMI 3) (odpływy: 1, źródła: 0, priorytet: 100, dostępne: tak)
off: Wyłączone (odpływy: 0, źródła: 0, priorytet: 0, dostępne: tak)
Aktywny profil: output:hdmi-stereo
Porty:
hdmi-output-0: HDMI / DisplayPort (priority: 5900, latency offset: 0 usec, available)
Właściwości:
device.icon_name = "video-display"
device.product.name = "E2240
"
Część profilu: output:hdmi-stereo
hdmi-output-1: HDMI / DisplayPort 2 (priority: 5800, latency offset: 0 usec, not available)
Właściwości:
device.icon_name = "video-display"
Część profilu: output:hdmi-stereo-extra1, output:hdmi-surround-extra1, output:hdmi-surround71-extra1
hdmi-output-2: HDMI / DisplayPort 3 (priority: 5700, latency offset: 0 usec, available)
Właściwości:
device.icon_name = "video-display"
device.product.name = "LG TV
"
Część profilu: output:hdmi-stereo-extra2, output:hdmi-surround-extra2
2. karta
Nazwa: alsa_card.pci-0000_0a_00.3
Sterownik: module-alsa-card.c
Właściciel modułu: 8
Właściwości:
alsa.card = "1"
alsa.card_name = "HD-Audio Generic"
alsa.long_card_name = "HD-Audio Generic at 0xfd700000 irq 58"
alsa.driver_name = "snd_hda_intel"
device.bus_path = "pci-0000:0a:00.3"
sysfs.path = "/devices/pci0000:00/0000:00:08.1/0000:0a:00.3/sound/card1"
device.bus = "pci"
device.vendor.id = "1022"
device.vendor.name = "Advanced Micro Devices, Inc. [AMD]"
device.product.id = "1457"
device.string = "1"
device.description = "HD-Audio Generic"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
Profile:
input:analog-stereo: Wejście Analogowe stereo (odpływy: 0, źródła: 1, priorytet: 60, dostępne: tak)
output:analog-stereo: Wyjście Analogowe stereo (odpływy: 1, źródła: 0, priorytet: 6000, dostępne: tak)
output:analog-stereo+input:analog-stereo: Analogowy dupleks stereo (odpływy: 1, źródła: 1, priorytet: 6060, dostępne: tak)
output:iec958-stereo: Wyjście Cyfrowe stereo (IEC958) (odpływy: 1, źródła: 0, priorytet: 5500, dostępne: tak)
output:iec958-stereo+input:analog-stereo: Wyjście Cyfrowe stereo (IEC958) + Wejście Analogowe stereo (odpływy: 1, źródła: 1, priorytet: 5560, dostępne: tak)
off: Wyłączone (odpływy: 0, źródła: 0, priorytet: 0, dostępne: tak)
Aktywny profil: output:analog-stereo
Porty:
analog-input-front-mic: Przedni mikrofon (priority: 8500, latency offset: 0 usec, not available)
Właściwości:
device.icon_name = "audio-input-microphone"
Część profilu: input:analog-stereo, output:analog-stereo+input:analog-stereo, output:iec958-stereo+input:analog-stereo
analog-input-rear-mic: Tylny mikrofon (priority: 8200, latency offset: 0 usec, not available)
Właściwości:
device.icon_name = "audio-input-microphone"
Część profilu: input:analog-stereo, output:analog-stereo+input:analog-stereo, output:iec958-stereo+input:analog-stereo
analog-input-linein: Wejście liniowe (priority: 8100, latency offset: 0 usec, not available)
Część profilu: input:analog-stereo, output:analog-stereo+input:analog-stereo, output:iec958-stereo+input:analog-stereo
analog-output-lineout: Wyjście liniowe (priority: 9900, latency offset: 0 usec, available)
Część profilu: output:analog-stereo, output:analog-stereo+input:analog-stereo
analog-output-headphones: Słuchawki (priority: 9000, latency offset: 0 usec, not available)
Właściwości:
device.icon_name = "audio-headphones"
Część profilu: output:analog-stereo, output:analog-stereo+input:analog-stereo
iec958-stereo-output: Wyjście cyfrowe (S/PDIF) (priority: 0, latency offset: 0 usec)
Część profilu: output:iec958-stereo, output:iec958-stereo+input:analog-stereo
我怎样才能实现这个目标?
答案1
每次重新启动时,Pulse Audio 都会将声音设备重置为HDMI
。为了使其保持设置,HDMI3
您需要告诉它停止自动切换。
禁用自动设备切换
当睡眠或关机期间信号丢失时,Pulse Audio 会自动配置为激活默认源(您的 HDMI)。恢复或重新启动后,声音设备仍位于 HDMI 上。要覆盖此设置,请告诉 Pulse Audio 永远不要自动切换声音设备:
- 编辑文件
/etc/pulse/default.pa
- 找到线
load-module module-switch-on-port-available
#
在行首插入 a以禁用自动端口切换- 保存文件并重新启动。
您无需重新启动即可pulseaudio -k
重新加载配置更改。
答案2
(接受的答案解决了用户的特定问题,但没有回答原始问题“如何通过脚本编辑 PulseAudio 配置”)
要通过终端更改 PulseAudio 配置,请使用以下命令:
pacmd set-card-profile <card> <new-profile>
其中<card>
是目标卡的索引或名称(在您的情况下为 HDA Nvidia)。要获取卡和配置文件名称,请使用pacmd
:
$ pacmd list-sinks
card: 1 <alsa_card.pci-0000_08_00.1>
...
properties:
device.profile.name = "hdmi-stereo" # Before
device.profile.name = "hdmi-stereo-extra2" # After
...
$ pacmd list-cards
name: alsa_card.pci-0000_08_00.1
...
Profile:
output:hdmi-stereo: <display name>
output:hdmi-stereo-extra2: <display name> # Target profile
...
对于你来说,情况是这样的:
pacmd set-card-profile alsa_card.pci-0000_08_00.1 output:hdmi-stereo-extra2