Last active
March 31, 2026 10:05
-
-
Save gudata/98abe72bf07e1f51437bf7b16a369ed4 to your computer and use it in GitHub Desktop.
Reset ubuntu spearkers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # | |
| # set_audio.sh — Configure audio output/input to Speakers analog stereo duplex | |
| # | |
| # HOW TO IDENTIFY YOUR SOUND CARDS, SINKS, SOURCES, AND PROFILES | |
| # --------------------------------------------------------------- | |
| # | |
| # 1. LIST CARDS (to find CARD name and available PROFILES): | |
| # pactl list cards | |
| # Look for "Name:" under each card entry — that is your CARD value. | |
| # Under "Profiles:" find the profile you want (e.g. "Analog Stereo Duplex"). | |
| # The profile key (left of the colon) is your PROFILE value. | |
| # Example: | |
| # Name: alsa_card.pci-0000_00_1f.3 | |
| # output:analog-stereo+input:analog-stereo: Analog Stereo Duplex | |
| # | |
| # 2. LIST SINKS (to find SINK name and OUTPUT_PORT): | |
| # pactl list sinks | |
| # Look for "Name:" — that is your SINK value. | |
| # Under "Ports:" find the port for speakers/headphones — that is OUTPUT_PORT. | |
| # Example: | |
| # Name: alsa_output.pci-0000_00_1f.3.analog-stereo | |
| # analog-output-speaker: Speakers | |
| # | |
| # 3. LIST SOURCES (to find SOURCE name and INPUT_PORT): | |
| # pactl list sources | |
| # Ignore monitor sources (names ending in .monitor). | |
| # Look for "Name:" on a real input — that is your SOURCE value. | |
| # Under "Ports:" find the mic port — that is INPUT_PORT. | |
| # Example: | |
| # Name: alsa_input.pci-0000_00_1f.3.analog-stereo | |
| # analog-input-internal-mic: Internal Microphone | |
| # | |
| # 4. QUICK SUMMARY commands: | |
| # pactl list cards | grep -E 'Name:|active profile|Profiles' | |
| # pactl list sinks | grep -E 'Name:|Ports' -A5 | |
| # pactl list sources | grep -E 'Name:|Ports' -A5 | |
| # --------------------------------------------------------------- | |
| set -euo pipefail | |
| CARD="alsa_card.pci-0000_00_1f.3" | |
| SINK="alsa_output.pci-0000_00_1f.3.analog-stereo" | |
| SOURCE="alsa_input.pci-0000_00_1f.3.analog-stereo" | |
| PROFILE="output:analog-stereo+input:analog-stereo" | |
| OUTPUT_PORT="analog-output-speaker" | |
| INPUT_PORT="analog-input-internal-mic" | |
| pactl set-card-profile "$CARD" "$PROFILE" | |
| pactl set-default-sink "$SINK" | |
| pactl set-default-source "$SOURCE" | |
| pactl set-sink-port "$SINK" "$OUTPUT_PORT" | |
| pactl set-source-port "$SOURCE" "$INPUT_PORT" | |
| pactl set-sink-volume "$SINK" 70% | |
| pactl set-sink-mute "$SINK" 0 | |
| pactl set-source-volume "$SOURCE" 30% | |
| pactl set-source-mute "$SOURCE" 0 | |
| # Unmute all running application streams and reset their volumes to 100% | |
| # so the master sink volume is the sole authority (disables per-app volume control) | |
| pactl list short sink-inputs | awk '{print $1}' | while read -r idx; do | |
| pactl set-sink-input-mute "$idx" 0 | |
| pactl set-sink-input-volume "$idx" 100% | |
| done | |
| echo "Audio configured: Speakers 70% unmuted | mic 30% unmuted | all app streams unmuted at 100%" | |
| notify-send "Audio Configured" "Speakers 70% · Mic 30% · All app streams unmuted" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment