Head_on_a_Stick wrote:samuele wrote:timidity file is /etc/init.d/timidity. How i can do that? How can i change this scripts making it as a service in /usr/lib/systemd/user like pulseaudio.service and be sure at the same time that it spawns after pulseaudio?
You don't need to change the service file at all, just call it in the ExecStart= line of a custom systemd user service with Requires=pulseaudio.service and After=pulseaudio.service in the [Unit] section. See also
http://0pointer.de/blog/projects/system ... ins-3.html
EDIT: or just add the timidity command to ~/.profile (for console sessions) or ~/.xsessionrc (for graphical sessions).
ok this is very useful, thank you!! And this works without breaking anything. Sadly i didn't waited for your answer and i configured pulseaudio as system-wide
I tested the system-wide version while waiting. So i post both the soultions here if some may need them.
The simplest and less invasive solution is the one you said: Just install all the base packages:
Code: Select all
sudo apt-get install timidity fluid-soundfont-gm
then create (with sudo) a systemd unit file, located under /usr/lib/systemd/user/timidity.service, with this content
Code: Select all
[Unit]
Description=Timidity
After=pulseaudio.service
[Service]
Type=simple
ExecStart=/usr/bin/timidity -Os -iA
[Install]
WantedBy=pulseaudio.service
now install and enable it
Code: Select all
systemctl --user enable timidity.service
systemctl --user start timidity.service
And it's done, started per-user.
The other solution, in order to get pulse/timidity to work as root system-wide, those are the steps:
To get it system-wide, follow the following steps (inspired by
https://raven4.cz/wp/pulseaudio-in-system-wide-mode/)
first install base packages
Code: Select all
sudo apt-get install timidity timidity-daemon fluid-soundfont-gm
edit (with sudo) /etc/pulse/daemon.conf, search the row
uncomment it and set it to yes
now make a backup of the files /etc/pulse/system.pa and /etc/pulse/default.pa, just in case you want to rollback, then symlink default.pa as system.pa
Code: Select all
sudo mv /etc/pulse/system.pa /etc/pulse/system.pa.bak
sudo cp /etc/pulse/default.pa /etc/pulse/default.pa.bak
sudo ln -s /etc/pulse/default.pa /etc/pulse/system.pa
now edit (sudo) /etc/pulse/default.pa, find the row
Code: Select all
load-module module-native-protocol-unix
and change it this way
Code: Select all
load-module module-native-protocol-unix auth-group-enable=true auth-group=pulse-access socket=/tmp/pulse-socket
now edit (sudo) /etc/pulse/client.conf, find the row
uncomment it and set it this way
Code: Select all
default-server = unix:/tmp/pulse-socket
now we need to add every user we want have access to pulseaudio in the account pulse-access. timidity will run as his own user, so we need to add it too. In my case i want the user root and my main user, samuele, so i'll do:
Code: Select all
usermod -a -G pulse-access root
usermod -a -G pulse-access samuele
usermod -a -G pulse-access timidity
now we need to create the custom pulseaudio.service file. so create a file in /etc/systemd/system/pulseaudio.service with this content
Code: Select all
[Unit]
Description=Pulseaudio
[Service]
User=root
Type=forking
ExecStart=/bin/pulseaudio --realtime --daemonize
Restart=always
[Install]
WantedBy=graphical.target
Now it's time to fix timidity.
Check if it's working with
if not, start it
check again, if everything it's working, whe have a generated service file in /run/systemd/generator.late/timidity.service
copy it to /etc/systemd/system
Code: Select all
sudo cp /run/systemd/generator.late/timidity.service /etc/systemd/system/timidity.service
now edit it (sudo) and in the file beginning search for
and change it this way
Code: Select all
After=remote-fs.target pulseaudio.service
In file ending add those two lines to make it installable
Code: Select all
[Install]
WantedBy=multi-user.target
Now it's time for cleaning. stop timidity and remove it from init.d
Code: Select all
sudo service timidity stop
sudo update-rc.d -f timidity remove
stop the per-user pulseaudio, disable it and clean your userdir config
Code: Select all
systemctl --user stop pulseaudio.socket
systemctl --user stop pulseaudio.service
systemctl --user disable pulseaudio.socket
systemctl --user disable pulseaudio.service
rm -Rf ~/.config/pulse/
now enable the new services
Code: Select all
sudo systemctl enable /etc/systemd/system/pulseaudio.service
sudo systemctl enable /etc/systemd/system/timidity.service
restart the machine aaaand.. it's done!