Skip to content

Commit

Permalink
Add extra arguments necessary for pulse
Browse files Browse the repository at this point in the history
Found here: jacknlliu/ros-docker-images#7
Also fixed typo in the config.

Tested using chromium in docker watching youtube.

Firefox seems to crash stil though.
  • Loading branch information
tfoote committed Dec 24, 2018
1 parent 8f002eb commit 125faa5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/rocker/extensions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import grp
import os
import em
import getpass
Expand Down Expand Up @@ -157,6 +158,8 @@ def get_environment_subs(self):
if not self.env_subs:
self.env_subs = {}
self.env_subs['user_id'] = os.getuid()
self.env_subs['XDG_RUNTIME_DIR'] = os.getenv('XDG_RUNTIME_DIR')
self.env_subs['audio_group_id'] = grp.getgrnam('audio').gr_gid
return self.env_subs

def get_preamble(self, cliargs):
Expand All @@ -167,7 +170,9 @@ def get_snippet(self, cliargs):
return em.expand(snippet, self.get_environment_subs())

def get_docker_args(self, cliargs):
return ' -v /run/user/%(user_id)s/pulse:/run/user/%(user_id)s/pulse --device /dev/snd' % self.get_environment_subs()
args = ' -v /run/user/%(user_id)s/pulse:/run/user/%(user_id)s/pulse --device /dev/snd '\
' -e PULSE_SERVER=unix:%(XDG_RUNTIME_DIR)s/pulse/native -v %(XDG_RUNTIME_DIR)s/pulse/native:%(XDG_RUNTIME_DIR)s/pulse/native --group-add %(audio_group_id)s '
return args % self.get_environment_subs()

def precondition_environment(self, cliargs):
pass
Expand Down
2 changes: 1 addition & 1 deletion src/rocker/templates/pulse_snippet.Dockerfile.em
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RUN mkdir -p /etc/pulse
RUN echo $'\n\
RUN echo '\n\
# Connect to the hosts server using the mounted UNIX socket\n\
default-server = unix:/run/user/@(user_id)/pulse/native\n\
\n\
Expand Down

0 comments on commit 125faa5

Please sign in to comment.