I have a Dell Optiplex 780 that I equipped with a NVIDIA GT 1030 video card. After installing the NVIDIA proprietary driver version 535.146.02 I noticed that pulseaudio does not work after resuming from suspend or hibernate. This is in particular true when trying to stream sound from firefox. I have found that I can get pulseaudio functional again with:
systemctl restart sound.target
However, this requires root privileges. I wonder whether there is a config file where I can add the line above so that it is read upon resuming from suspend or hibernate? If there are any other suggested solutions how to resolve the pulseaudio issue upon resuming from suspend/hibernate I would appreciate to know.
Dec 09 19:24:11 venere systemd-sleep[29248]: INFO: Skip running /usr/lib/systemd/system-sleep/grub2.sleep for suspend
Dec 09 19:24:06 venere suspend[29257]: nvidia-resume.service
Dec 09 19:24:05 venere systemd-sleep[29187]: System returned from sleep state.
Dec 09 19:24:11 venere logger[29257]: <13>Dec 9 19:24:06 suspend: nvidia-resume.service
Dec 09 19:24:06 venere systemd[1]: nvidia-resume.service: Deactivated successfully.
Dec 09 19:24:06 venere systemd[1]: Finished NVIDIA system resume actions.
@gianluca44 if you copy /usr/lib/systemd/system/nvidia-resume.service to /etc/systemd/system/nvidia-resume.service and edit the file in the [Service] to include;
@malcolmlewis Sorry I had missed your post above. Just want to make sure I do it correctly:
Why do I need a “+” in “ExecStartPost=+/usr/bin/systemctl restart sound.target”?
If I copy /usr/lib/systemd/system/nvidia-resume.service to /etc/systemd/system/nvidia-resume.service don’t I end up with two versions of the same file? I mean, are both files going to be executed?
Are you suggesting the file /etc/systemd/system/nvidia-resume.service should then look like this:
If the executable path is prefixed with “+” then the process is executed with full privileges. In this mode privilege restrictions configured with User=, Group=, CapabilityBoundingSet= or the various file system namespacing options (such as PrivateDevices=, PrivateTmp=) are not applied to the invoked command line (but still affect any other ExecStart=, ExecStop=, … lines). However, note that this will not bypass options that apply to the whole control group, such as DevicePolicy=, see systemd.resource-control(5) for the full list.
Files in /etc override any system defaults plus on an update your changes don’t get replaced any changes by the system admin get done in / etc for this reason.
A full copy of the service file will override any newer vendor version of the service, thus disabling all updates to the service. You may want to create a drop-in by running systemctl edit nvidia-resume.service:
I tried the suggestion by @malcolmlewis. It did not work at first even after systemctl daemon-reload. So I rebooted. Sound works only the after the first time that I hibernate. If I hibernate a second time and resume, then the sound does not work, unless I restart the sound.target manually. I may have to try a different solution.
Please, always use the </> button and not the " button when posting code/computer text.
It now looks as if the quotes around $1 are of the wrong type. But that could be something the forum’s software is doing to “normal” text.
One interesting thing is that if I launch vlc or mplayer -ao pulse and play a short video/audio file, then sound can be streamed from firefox. It seems that using vlc or mplayer -ao pulse unlocks something and then firefox works correctly with pulseaudio.
I may try to write a small script that plays sound for very short (maybe with volume off) and then have a wrapper for hibernate/suspend.
PS: I did try earlier by restarting pulseaudio as user but that didn’t work either.