Valheim

Valheim

Annoying no Audio issue on Linux
Dear Devs,

please be aware that your game starts each and every time on my Linux without Audio.

The workaround is very(!) annoying: I have to have the System Settings open when launching Valheim, toggle from Valheim to the System Settings and switch the Audio Output back and forth. It does not help that the Audio Output was correctly set when launching Valheim, the toggle is mandatory for having Audio active in the game.

Such may be excusable in Early Access, but if you ever want to release the game, this should be fixed.

My details:

Valheim Files: native Linux
Distro:Suse Leap 15.5
Steam:Freedesktop.org SDK 23.08 (Flatpak runtime)
Kernel:5.14.21-150500.55.36-default
RAM:32 GB
GPU Driver:4.6 Mesa 23.2.1 (git-49a47f187e)
GPU:AMD Radeon RX 5500 XT (navi14, LLVM 16.0.6, DRM 3.49, 5.14.21-150500.55.36-default)
CPU:AMD Ryzen 5 3600 6-Core

Btw: Same Audio issue is given if playing with Windows Files using GE-Proton8-25.
Last edited by BierPizzaChips; Dec 19, 2023 @ 4:56pm
< >
Showing 1-3 of 3 comments
BierPizzaChips Dec 19, 2023 @ 8:23pm 
@Tuxedo: Guess how i found the workaround.:steammocking: Always good not doing premature conclusions. But i did not find that content shared in your link, which is good news and appreciated. Thanks.:steamhappy:
psilimit Mar 9, 2024 @ 10:08pm 
Some help for you guys.

Valheim on Linux keeps defaulting to the WRONG output device. Unplugging and replugging works because Pulse Audio wants to change audio streams over to new devices (this can be unset).

A better solution is to open PavuControl (avilable for all major distributions...it's an audio stream controller) and change Valheim (listed as FMOD Ex App...) to the correct sound device. If that sounds minorly cumbersome, well, it is. That said, grab PavuConrol anyways, it solves many issues, lets you easly change things to and from your headset, speakers, hdmi, controller speaker. Also, you can set an audio device default...but Valheim will not respect it.

Solution #2: We use Linux. Make a script!

First lets find our output devices:
<code># pactl list short sinks</code>
<code>50 alsa_output.usb-Sony_Interactive_Entertainment_DualSense_Wireless_Controller-00.analog-surround-40 PipeWire s16le 4ch 48000Hz IDLE
52 alsa_output.usb-sky_win_HS011_dongle_20221215185141-00.analog-stereo PipeWire s16le 2ch 48000Hz IDLE
54 alsa_output.pci-0000_04_01.0.analog-stereo PipeWire float32le 2ch 48000Hz IDLE</code>

Next lets find our audio streams (with Valheim Running):
<code># pactl list short sink-inputs</code>
<code>1230 50 1229 PipeWire s16le 2ch 48000Hz</code>

We can move Valheim over to the speakers with:
<b># pactl move-sink-input 1230 54</b>
But this is even MORE cumbersome!
Again, this is Linux, so lets use it!
We can use SED to extract the stream ID and we can use the device symbolic name (the device ID can change).
<code># pactl move-sink-input $(pactl list short sink-inputs | sed 's/\s.*$//') alsa_output.pci-0000_04_01.0.analog-stereo</code>
(Please use your won sound card...don;t play Valheim on MY sound card!)

This is good if only Valheim is outputting audio...not so good if you're playing music, chatting in Discord, have Firefox open with a paused YouTube video. Time for ONE more fix.

Make a new file (call it ValSound.sh or some such) and make it executable with chmod +x ValSound.sh and put it in your path (or include it's full path in the Steam launch options).

<code>
#!/bin/bash

# Set the name of your preferred soundcard for Valheim here!
# Get the name from "pactl list short sinks"
SOUNDCARD="alsa_output.pci-0000_04_01.0.analog-stereo"

# Put this file (and make it executable, chmod +x) in your path
# or specify it's location manualy.
# Change your Valheim launch options in steam to somthing like:
# %command% & (sleep 10; ValSound.sh)
# OR
# %command% -windowed +connect YourServer:2456 -console & (sleep 10; /home/MyUserName/ValSound.sh)

IFS=$'\n' read -rd '' -a array <<< "$(pactl list sink-inputs)"
COUNTER=0

for i in "${array[@]}"
do
#echo $COUNTER: $i
if [[ $i == *"FMOD Ex App"* ]]; then
#echo "$i"
f=$COUNTER
for (($f-1; f>=0; f--)); do
#echo $f
if [[ ${array[$f]} == *"Sink Input #"* ]]; then
VALHEIM=$(echo ${array[$f]} | sed 's/Sink Input #//')
#echo $VALHEIM
f=0
fi
done
fi
COUNTER=$((COUNTER + 1))
done

echo $VALHEIM $SOUNDCARD
pactl move-sink-input $VALHEIM $SOUNDCARD
</code>

Finally, change your Valheim launch options in steam to something like:
<b>%command% & (sleep 10; ValSound.sh)</b>
OR
<b>%command% -windowed +connect YourServer:2456 -console & (sleep 10; /home/MyUserName/ValSound.sh)</b>

10 seconds after Valheim is starts this will move it to the correct output device. You could also just execute the script manually.

This crazy thing took me like nearly 4 hours to get automated (and I'd been searching for a solution for an existing solution for sometime), so I truly hope it can help some of you guys.

Also, here's a link the the Valheim bug report: The Bug![valheimbugs.featureupvote.com] MaCarBre put up the Bug Report. Please go upvote it so they fix it.
Last edited by psilimit; Mar 9, 2024 @ 10:10pm
_tacirus_ May 24, 2024 @ 5:35pm 
Originally posted by Tuxedo:
As soon as the Coffee Stain and Iron Gate Logo is gone and the Home Screen from
the Game is visible, i unplug and re plug my Headphones again, and the Sound is back.
Thank you for the info. Guess what, I couldn't come up to this simple idea myself :) Now I play with sound!
< >
Showing 1-3 of 3 comments
Per page: 1530 50

Date Posted: Dec 19, 2023 @ 4:53pm
Posts: 3