Making PulseAudio 10 work with X Windows and Firejail

I was unable to find much information about this issue so it’s either somewhat obscure or I’m terrible at searching for things. Probably both.


I originally ran into this problem when trying to run Firefox in Firejail using the standard Firejail profile for Firefox. Firefox ran fine, except there was no audio. I found that this was a known issue documented here, but unfortunately none of the suggested fixes had any effect. The page states that newer versions of PulseAudio do not exhibit that issue, so that is not really surprising.

I did some searching and found others with related issues (see the related links at the end of this post), but no solutions matched my problem. Based on some of those discussions I tried to run speaker-test with Firejail (both with and without --noprofile), but I received a “connection refused” message in both cases. After some experimentation I found that if I ran speaker-test in Firejail after booting up, but before starting X Windows, it worked. This was the case even if I first used an audio program in the terminal (e.g. a music player) before attempting to run a program with Firejail.

Extra background – The system in question runs Slackware Linux (-current) with PulseAudio 10, starts up into runlevel 3 and uses startx to load X Windows.


I was able to resolve the issue by adding the following to my .xinitrc before starting the window manager. It starts PulseAudio via the start-pulseaudio-x11 program, which (according to the man page) adds access credentials to the PulseAudio server to the X11 root window and registers it in the X11 session manager.

pulseaudio --kill

I doubt this is an issue for those that start their system using a graphic display manager, although I have not tested that.

Possibly Useful PulseAudio Links

Accessing GUI Applications with “su” in X Windows

There are many solutions for accessing GUI applications (in X Windows). Several are described in this excellent post on the Arch Linux Wiki.

However, I needed a different solution as I frequently “su” to different accounts in the terminal to perform different tasks – I normally don’t just start one application and then exit back to the original user.

I ended up finding an answer in the xhost man pages (go figure). The command below should be run as the user who started the X Windows session. Substitute the actual username of the account for the “su” in place of “USERNAME”.

xhost +"si:localuser:USERNAME"

The si prefix stands for “server interpreted”. This syntax allows us to grant access to a single local user. For more information check out the man pages for xhost and Xsecurity.

Managing the “internalBorder” background color in rxvt-unicode

Setting the Internal Border Size

While by no means an “essential” setting for many users, the internalBorder setting in rxvt-unicode can go a long way towards making the terminal more readable or simply looking more the way you want. It adds some padding between the edge of the terminal window and the start of the text, both at the top/bottom and the left/right of the window. This is especially useful if you use a tiling window manager and do not otherwise have spacing between windows.

To set the internal border, simply add the setting below to your Xresources file. In this case it sets the border to five pixels.

URxvt.interalBorder: 5

You should be able to use xrdb -load filename (replace existing properties) or xrdb -merge filename (merge with existing properties) to load the settings without restarting X Windows. You will need to open a new terminal window to see the effects.

Changing the Background Color

If you set the background color of your terminal dynamically with a script such as base16-shell, you may notice that the background color of the internal border of the rxvt-unicode window is not set.

The internal border looks for the number 708 in the escape sequence used for setting colors, whereas the sequence for setting the normal background color uses 11. For example, to set the background color to a nice grey color (#c3c3c3), you can run the command:

printf '\033]11;rgb:c3/c3/c3\007'

The internal border background color can be set to the same value using:

printf '\033]708;rgb:c3/c3/c3\007'

In terms of the base16-shell scripts, one option is to modify the template, copying the line that sets the background to also set the internal border background color (the default.moustache file here). In that case you’ll need to rebuild the scripts using one of the builders as shown here.

You can also use a shell command utilizing sed like the one below to copy the line that sets the background color in the scripts and create a new line to set the internal border color.

Example Shell Command:

for script in ${BASE16_SCRIPTS_DIRECTORY}/*.sh; do
    sed -i 's/printf \$printf_template_var 11 \$color_background/&\
    \printf $printf_template_var 708 \$color_background/' ${script}

Modification Result:

printf $printf_template_var 10 $color_foreground
printf $printf_template_var 11 $color_background
printf $printf_template_var 708 $color_background

Note that the base16-shell scripts have special handling for iTerm2 and tmux, so if you use either of those tools, you should also update those sections accordingly.

References (rxvt-unicode internalBorder) (changing terminal colors) (base16-colors)