Unable to set permanent audio output (solved)

hal_sk

New Member
Joined
May 25, 2020
Messages
20
Reaction score
4
Credits
206
[SOLVED, see the end]
Hello,
I use my Ubuntu PC with my TV using HDMI cable for video and audio.
In Ubuntu I have 2 possible audio outputs to choose from:
  1. HDMI
  2. SPDIF
After I select desired HDMI option it works fine until I reboot the PC. After that, output reverts to SPDIF. Ubuntu is not saving the setting. Is it a bug? If yes, where can I publish it?
Then I tried to work around it by creating systemd service that will run command to change audio output to HDMI after each reboot.
In my case the command is:
Code:
pacmd set-default-sink "alsa_output.pci-0000_01_00.1.hdmi-stereo"
It works when running the command as user via terminal window.
Problem is, it does not work when running it using systemd service unit. In the logs it says:
No PulseAudio daemon running, or not running as session daemon
Then I have tried to put the command into "Startup Applications Preferences" via GUI. But it also does not work.

EDIT (solution):
During writing this post, I have used user-wide systemd service unit to run my script with "pacmd" command instead of system-wide systemd. And it finally works.
System wide systemd is located at: "/etc/systemd/system"
User wide systemd is located at: "~/.config/systemd/user"
 
Top