Debian-minimal template for sys-audio

My sys-audio displays the same output uness I perform the procedure outlined in my earlier post:

Each time I start QubesOS on my Librem 14, I run the following script:

#!/bin/bash

qvm-start --quiet sys-audio
qvm-shutdown --wait sys-audio
qvm-start --quiet sys-audio
qvm-shutdown --wait sys-audio
qvm-start --quiet sys-audio
sleep 3
qvm-run --pass-io sys-audio "amixer sset Master 0%"

This is also important:

If you have opted for a disposable sys-audio, then I would recommend testing my hypothesis. I did this by starting sys-audio and using the pavucontrol package to check if “Dummy Output” changed to “Built-in Audio Analog Stereo” or not. If not, shutdown sys-audio and try again. If your sys-audio is non-disposable, then it might be unpredictable like my experience.

Hopefully this is helpful. Otherwise, maybe someone else could share their experiences.

1 Like

Thanks for responding.

I basically gave up on debian minimal for this at some point then spent another big long thread trying to get fedora to work (NOT my preference but they seemed to be having better luck with it), with the same result–my machine would pretend to play music, but nothing would come out of my speakers because sys-audio wouldn’t recognize my device. At this point, basically my debian-based sys-audio is long gone.

(Fedora six ring rodeo trying to get that to work: Setting up an audio VM - #28 by logoerthiner)

Nevertheless I tried cycling both a disposable and non-disposable version of that template like you talked about here…with zero success.

It’s just as well, honestly. If I have to do that every time I start it, it’s a broken piece of junk I don’t want on my system. Assuming I went with the disposable, how long would it be before my audio quit working because now it needs to be cycled 5 times instead of 3?

If it won’t work the first time it comes up, it’s crap.

EDIT TO ADD: Recreated my deb11 minimal stuff…same result. No amount of repetition will find the driver I seem to be missing.

1 Like

Ok, I finally resolved the hardware part (making pulseaudio recognize my soundcard).

After a clean installation as post #2, only root has access to audio. You can identify that by running alsamixer and pulseaudio as root, and see the differences from running them as user. To fix this, you need to remove pulseaudio in the template, and reinstall those removed packages. This will make everything happy.

BTW, just a notice, gnome-keyring isn’t necessary for this setup.

2 Likes

I’m probably going to love this…once I figure out exactly what you’re saying!

You’re saying to NOT install pulse audio in the template? Then you say to install “removed packages”. Which removed packages?

I note that two other users have liked this, so they must have understood you and I feel a bit stupid having to ask for clarification.

After following the steps in post #2, you’ll get a sys-audio which correctly receives audio streams from other qubes, but cannot play sound. The reason is that after all of these, in sys-audio , only root has the privilege to talk to the soundcard. So the regular pulseaudio instance running as user doesn’t know your soundcard.

To make the regular user user have access to the soundcard, you have to shutdown sys-audio, boot up its template, remove pulseaudio, and reinstall those removed packages. After this, pulseaudio running as user will see your soundcard in Output devices.

and reinstall those removed packages.

That’s where I’m getting confused.

What “removed packages”? Pulseaudio itself? That’s just one package, I think. (And even if so…I am not sure I can do an apt-install except with sudo.)

Thank you for your patience.

[next task for someone…you? me, if this works for me? Figure out how to install it properly the first time. Ideally this could be done in salt, somehow, without a special go-back-and-fix-it sequence that must be done manually. I have a couple of VMs that have such requirements (e.g. a printer driver that apparently must be configured manually, likewise with a couple of browser qubes) and I really don’t like it.]

Yes, Qubes needs help from the Community for that.

Well I don’t want to go too far into the weeds, here, but the printer driver installs fine, but it must be run–with its gui–to tell it what printer to connect to–I’ve never found a command line method (that doesn’t require interaction) for it. I just have to remember, when regenerating all of my minimal templates, that after generating THAT one (all of the two dozen or so subsequent templates are derived from it) I need to run the configuration. After that, it works fine.

Not trying to solve that problem here, I was just giving examples of things that I can’t automate, as much as I would like to, whilst hoping this doesn’t get added to the list.

Not sure why you brought up bluetooth; I just want to play music and videos.

When you remove pulseaudio, there are some packages depending on it that will also be removed. I didn’t mention all of them, because I’m not sure which package is the vital one. It’s easy for you to know and copy the list of packages to be removed when running apt remove xxx, then key-in apt install and paste that list.

It depends on how you run this command. If you manage the qube through Qubes Manager’s open a console in the qube, you will be able to login as root and ignore that sudo. There are certainly other ways that require a sudo to work. You have to distill the crucial information, and adapt those insignificant part to your own use case.

1 Like

Ok…so I went into my template, did a sudo apt remove on pulseaudio. I then did a sudo apt install on all of the packages.

I shut down the template and started pavucontrol in sys-audio. It showed the output device as “Dummy output.”

OK, so that didn’t work.

I repeated the above process, only in the template xterm I did “su” to become root and did not do sudo; I just did apt remove and apt install. After shutting down the template and restarting pavucontrol in sys-audio…same result, output is “Dummy Output.”

Trying to “open a console in the qube” in Qube Manager simply starts up a disposable which shows me a blank terminal with no prompt. It’s not running on the template. (So what is it good for?)

In any case, I’m stuck. Please instead of expecting me to play a guessing game as to how to reinstall the thing, just tell me the command(s) you used that would install the thing not as root.

Just to clarify. You did this in sys-audio’s template and sys-audio was shut down while template has been manipulating with?

This means actually, restarting sys-audio after template shutdown? Rebooting Qubes doesn’t help?

In both cases I shut down sys audio, I did not reboot the entire system. And of course I shut down the template before restarting sys audio.

Since sys-audio is what is interfacing with the device (albeit doing so poorly), that should be sufficient.

Of course I had to reboot to listen to audio again, since the audio device won’t go back to being controlled by dom0 once it has been pulled away from dom0.

1 Like

So strange… I’d suggest you to open separate topic for your issue and to start over from the very beginning, with the system rebooted without sys-audio existing.

Just for clarification, I’m to update the guide posted in post #2. And because I cannot edit that post, I’ll post it here.
Creation of sys-audio:
In dom0:

  1. Copy your debian-11-minimal to name deb11-audio.

In deb11-audio:

  1. Install qubes-usb-proxy qubes-input-proxy-sender alsa-utils alsa-oss alsa-ucm-conf alsa-firmware-loaders without --no-install-recommends.
  2. Install pavucontrol pulseaudio qubes-core-admin-client qubes-gui-daemon-pulseaudio pulseaudio-qubes with --no-install-recommends.
    3.1. Remove pulseaudio through apt. Note that some other packages are also removed. Copy the list of removed packages in the terminal.
    3.2 Install those removed packages whose names were copied, including pulseaudio.
  3. Create a file at /etc/modprobe.d/, name it 50-snd.conf, and put options snd_hda_intel power_save=0 in it. Shutdown the template.

In dom0:

  1. Create a appvm named sys-audio based on deb11-audio. Assign your PCI audio devices to it. Configure them to be no-strict-reset.
  2. Create 50-sys-audio.policy in dom0 at /etc/qubes/policy.d/, enter those policy lines at #2.
  3. In Qubes-Settings of sys-audio, turn to “Services” page, Add a (custom…) service called “audiovm”.
  4. Run qubes-prefs default_audiovm sys-audio. Boot up sys-audio.

At this point, you have a working sys-audio. Any newly started qube is using sys-audio as its audio sink. You can start a new disposable and play music in it.

To adjust volume:
Run pavucontrol in a terminal in sys-audio. You’ll have a graphical interface to do adjust the volume.

To enable bluetooth:
See @dom0’s detailed guide.
Please note that if you are using a wireless card that also provides bluetooth, then the bluetooth device might appear in the Device Widget as a strange string of numbers, for example, 8087_2345.

To enable shortcut adjusting volume:
Add a shortcut based on your desktop environment (Xfce, KDE, etc.) to run the command qvm-run sys-audio 'amixer sset Master 2%+', which will turn up the volume.
Add a shortcut based on your desktop environment (Xfce, KDE, etc.) to run the command qvm-run sys-audio 'amixer sset Master 2%-', which will turn down the volume.
Add a shortcut based on your desktop environment (Xfce, KDE, etc.) to run the command qvm-run sys-audio 'amixer sset Master toggle', which will toggle the audio between muted and unmuted.

The shortcut can be the default Fn+F1/2/3 combinations. For KDE, no further config is required. For Xfce4, you might have to disable some audio related services in dom0, in order that your shortcut is correctly passed to sys-audio. That part is beyond this post and will not be discussed.

2 Likes

Your instructions read to copy debian-11-minimal to deb11-audio, then install to deb11-minimal. Typo?

On a related note; I’ll be able to try this on a different system (as well as the one I had trouble with) now as I am converting my Librem-13v3 to Qubes.

Yes, thank you.

If you configure the shortcuts to run a script instead of a single command, you can create scripts that will adjust the volume and also display the current setting as a notification.

Here is a script for increasing the volume and displaying the current volume after the adjustment has been made:

#!/bin/bash

qvm-run --pass-io sys-audio "amixer sset Master 2%+"

VOLUME=$(qvm-run --pass-io sys-audio "amixer sget Master | awk -F 'Left:|[][]' '{ print \$3 }'")

notify-send -t 1 ${VOLUME}

To make the script for decreasing the volume, just copy the script above and change 2%+ to 2%-. You can of course change the 2 to the increment of your choice.

Here is the script for toggling between audio off (mute) and audio on (unmute) and then displaying the current state:

#!/bin/bash

qvm-run --pass-io sys-audio "amixer sset Master toggle"

STATE=$(qvm-run --pass-io sys-audio "amixer sget Master | awk -F 'Left:|[][]' '{ print \$5 }'")

notify-send -t 1 ${STATE}

Note that it will only display off or on to show whether audio is off (muted) or on (unmuted).

1 Like

@dom0 notify-send doesn’t appear to be part of the minimal template, by the way.

EDIT. Never mind, your scripts are meant to be in dom0.

Step 3: You’re installing pulseaudio (plus an assortment of other packages).
Step 3.1: You’re removing pulseaudio [which removes a group of things].
Step 3.2: You’re reinstalling everything removed in step 3.1

How does this make sense? Is there something different about the way one does the (re) install in step 3.2?

I’m not skilled enough to tell between. I guess it’s some user group problems, because without this step, it seems that pulseaudio and alsa are running as root, so no userspace programs (qubes-daemon, pavucontrol) will be able to communicate with them.