Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Get sound in Steam chroot installation?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gamers & Players
View previous topic :: View next topic  
Author Message
wintcape
n00b
n00b


Joined: 28 Aug 2022
Posts: 4

PostPosted: Mon Nov 28, 2022 4:16 pm    Post subject: Get sound in Steam chroot installation? Reply with quote

Here is my script to run Steam from inside a chrooted environment with a user 'steam':
Code:
#!/bin/sh

ARCH=linux64
DIR=/opt/steam

# ========== DO NOT MODIFY BELOW THIS LINE ========== #

mount --types proc  /proc                   $DIR/proc
mount --rbind       /sys                    $DIR/sys
mount --make-rslave $DIR/sys
mount --rbind       /dev                    $DIR/dev
mount --make-rslave $DIR/dev
mount --rbind       /run                    $DIR/run
mount --make-slave  $DIR/run
mount --rbind       /var/db/repos/gentoo    $DIR/var/db/repos/gentoo
mount -o bind       /dev/pts                $DIR/dev/pts

xhost +local:
$ARCH chroot $DIR su -c 'steam -no-cef-sandbox' steam
xhost -local:

umount  --verbose -l            $DIR/proc
umount  --verbose -l            $DIR/sys
umount  --verbose -l            $DIR/dev
umount  --verbose -l            $DIR/run
umount  --verbose -l            $DIR/pts
umount  --verbose -l            $DIR/var/db/repos/gentoo


This launches Steam and Steam games fine, but I use Pulseaudio and pulsemixer for sound, and no entries appear in the pulsemixer menu for any Steam games that I run. Sound works on all my non-chroot applications. What do I have to set up to get sound working in the chroot environment?
Back to top
View user's profile Send private message
capezotte
n00b
n00b


Joined: 13 Nov 2022
Posts: 7
Location: South America

PostPosted: Mon Nov 28, 2022 5:07 pm    Post subject: Reply with quote

The quickest solution is running your chroot under your UID. By default, XDG_RUNTIME_DIR (where the D-Bus and PA IPC endpoints are located - usually /run/user/$(id -u)) can only be accessed by your UID, so applications under your "steam" UID are locked out of it.

If you're chrooting steam for security purposes/due to not trusting proprietary software, I'd rather use Flatpak or Firejail. Allowing chrooted applications to access the "outside" D-Bus without introducing easy sandbox escapes involves ultimately duplicating what these solutions already do.
Back to top
View user's profile Send private message
wintcape
n00b
n00b


Joined: 28 Aug 2022
Posts: 4

PostPosted: Mon Nov 28, 2022 8:13 pm    Post subject: Reply with quote

capezotte wrote:
The quickest solution is running your chroot under your UID. By default, XDG_RUNTIME_DIR (where the D-Bus and PA IPC endpoints are located - usually /run/user/$(id -u)) can only be accessed by your UID, so applications under your "steam" UID are locked out of it.


Running $(id -u steam) inside the chroot and $(id -u) outside the chroot yields the same UID. What else would I need to change?
Back to top
View user's profile Send private message
capezotte
n00b
n00b


Joined: 13 Nov 2022
Posts: 7
Location: South America

PostPosted: Mon Nov 28, 2022 11:31 pm    Post subject: Reply with quote

Arch wiki people report also needing to bind /var/lib/dbus inside the chroot. PA in my chroot works just fine without it, but it might help you.

While you're at it, does paplay some_file.wav work in your chroot?
Back to top
View user's profile Send private message
wintcape
n00b
n00b


Joined: 28 Aug 2022
Posts: 4

PostPosted: Tue Nov 29, 2022 4:37 pm    Post subject: Reply with quote

capezotte wrote:
Arch wiki people report also needing to bind /var/lib/dbus inside the chroot. PA in my chroot works just fine without it, but it might help you.

While you're at it, does paplay some_file.wav work in your chroot?


Added the following line to my chroot script:
Code:
mount --rbind       /var/lib/dbus           $DIR/var/lib/dbus


This happens in chroot when trying to paplay:
Code:
 # paplay sound.wav
Connection failure: Connection refused
pa_context_connect() failed: Connection refused


Playing the same sound outside the chroot works.
Back to top
View user's profile Send private message
capezotte
n00b
n00b


Joined: 13 Nov 2022
Posts: 7
Location: South America

PostPosted: Tue Nov 29, 2022 10:28 pm    Post subject: Reply with quote

Just to be sure, is XDG_RUNTIME_DIR kept in the environment after you sudo? `sudo -E' (or adding it to env_keep in sudoers) should do it.

(For bonus info, try strace -e connect paplay ... inside the chroot -- it should have a line with sun_path="$XDG_RUNTIME_DIR/pulse/native").

I've renamed the user inside my chroot and it still worked (so username 'steam' being the problem is ruled out); it failed with the exact error message you posted after unsetting it.
Back to top
View user's profile Send private message
rh
n00b
n00b


Joined: 19 Sep 2006
Posts: 58

PostPosted: Mon Dec 05, 2022 8:47 am    Post subject: Reply with quote

I just run Pulseaudio system-wide.

https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/SystemWide/
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gamers & Players All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum