Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: Ubuntu 22.04 - No sound from frontal case jack AUX

  1. #11
    Join Date
    Mar 2023
    Beans
    26
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: Ubuntu 22.04 - No sound from frontal case jack AUX

    Stopped working again

    Don't know why...

    Still this return correct...
    Code:
    > cat /usr/share/alsa/ucm2/USB-Audio/USB-Audio.conf | grep 0db0:b202
            # 0db0:b202 MSI MAG Z690 Tomahawk Wifi
    I also tried to re-apply steps, but with no lucky...

    What could be happened this time ?

  2. #12
    Join Date
    Mar 2023
    Beans
    26
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: Ubuntu 22.04 - No sound from frontal case jack AUX

    I temporary solved this issue by applying following workaround (dirty solution).

    Created systemd user service:

    Code:
    > cat $HOME/.config/systemd/user/front-headphones-switch-handler.service 
    [Unit]
    Description=Run front-headphones-switch-handler
    
    [Service]
    ; Type=oneshot
    Type=simple
    ExecStart=/usr/local/bin/front-headphones-switch-handler
    Restart=on-failure
    RestartSec=5
    
    [Install]
    WantedBy=default.target
    And bash script:

    Code:
    > cat /usr/local/bin/front-headphones-switch-handler
    #!/bin/bash
    
    TARGET_DEVICE="Headphones"
    
    while true; do
        SINK_SELECTED_STATUS=`cat $HOME/.front-headphones-sink-selected-status`
    
        if [ `pactl list sinks short | grep $TARGET_DEVICE | wc -l` -lt 1 ]; then
            pacmd load-module module-alsa-sink sink_name=$TARGET_DEVICE sink_properties=device.description=$TARGET_DEVICE device=hw:Audio,1 control='PCM',1
            pactl set-default-sink alsa_output.usb-Generic_USB_Audio-00.analog-stereo 2>/dev/null
        fi
    
        are_front_headphones_attached=$(pacmd list-sinks | grep 'analog-output-headphones' | grep active | wc -l)
        if [ $are_front_headphones_attached -gt 0 ]; then
            if [ "$SINK_SELECTED_STATUS" == "FALSE" ]; then
                pactl set-default-sink "$TARGET_DEVICE" 2>/dev/null
                
                if [ $? -eq 0 ]; then
                    echo TRUE > $HOME/.front-headphones-sink-selected-status
                else
                    notify-send "front-headphones-switch-handler" "ERROR in setting front-headphones as output device"
                fi
            fi
    
        else
            is_speaker_already_default=$(pacmd list-sinks | grep 'analog-output-speaker' | grep active | wc -l)
            if [ $is_speaker_already_default -gt 0 ]; then
                if [ "$SINK_SELECTED_STATUS" == "FALSE" ]; then
                    sleep 0.5
                    continue
                fi
            fi
    
            pactl set-default-sink alsa_output.usb-Generic_USB_Audio-00.analog-stereo 2>/dev/null
            
            if [ $? -eq 0 ]; then
                echo FALSE > $HOME/.front-headphones-sink-selected-status
            else
                notify-send "front-headphones-switch-handler" "ERROR in setting speaker as output device"
            fi
        fi
    
        sleep 0.5
    done
    
    exit 0
    So that each time I attach my headphones to the front AUX jack, the bash daemon detect them and it switches to new dedicated sink for redirecting the audio.
    Last edited by ricciolino; December 13th, 2023 at 03:47 PM.

Page 2 of 2 FirstFirst 12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •