Just make sure you test a reboot. It might not work as expect. But there is a fix for that.
ok, so as not to look silly XD make sure to run:
systemctl start mute-on-idle.service
and everything looks and sounds normal.
If the solution is simple, you could put it in case another person needs it.
and a question before I go, what is the correct way to add more users in this section:
You only need to run it after you made a change to the service file. Not every time you want to start the service.
This command starts the service, but does not make sure it starts automatically after reboot. If you not used the enable command, the service is not running after reboot. If you want to use it after reboot, you need to enable it once.
You can’t. A systemd system service can only run for one user.
Maybe it would be better to use a systemd user service. This also would make sure it starts only after you locked in. I fear the systemd system service will fail, because it start way to early, if you enable it.
Thank you very much for the recommendation, but now I am experimenting with these two files:
Comment=una vez lanzado el canal de altavoz y auriculares se silencia por desuso
and this script call-mute:
OLDEST_PID=$(pgrep -o 'call-mute')
test $OLDEST_PID && pgrep 'call-mute' | grep -vw $OLDEST_PID | xargs -r kill
while [ true ] do ./mute-on-idle sleep 0.5 done
The use of the service, right now I have it as plan B, because I cannot close the terminal window that opens when I log in.
But at least I know it works and that I wouldn’t hesitate to use it if I needed it or if it offered more advantages over my plan A.
Ok, I have to give you updated information, the terminal window was not opened by the service, it was done by another application that I configured related to this same issue, then I proceeded to undo everything that could cause confusion, re-enable the service, restart, and the derminal window did not appear again, the process started correctly because I could see it running in the task manager, but I was surprised that it consumes up to 5 GB of ram memory, crazy.
I am going to make small adjustments to finalize the small project and if there is something of importance to communicate, I will.
the consumption of the 5 GB in ram was because I wanted to run:
In the same script, eliminate the lines that caused this consumption and everything is in order, nothing strange in sight.
the final script would be just this:
#!/bin/bash while [ true ] do /home/jhonatan/Documentos/ejecutable-comando/mute-on-idle sleep 1 done
You maybe want to put the content of
/home/jhonatan/Documentos/ejecutable-comando/mute-on-idle in your final script.
There is no good reason to start a script that then starts another scrip, if they are relatively simple.
Also putting scripts in your Document folder is maybe not the best place in the long run. Some think a better place for a final script or program might be
/home/jhonatan/.local/bin or if everybody one the system should be able to start the script
in fact a few minutes ago, I ran into a small bug when testing from terminal, I had to make the change you mention. XD
I had not thought about it until now, it sounds practical and safe as it is a hidden folder.
I would also like to communicate that I think I already have something quite stable, I will test it thoroughly before I publish it so that others can also benefit from my little struggle XD.
sorry to say that systemd-service is not part of the final result.
This is largely due to the fact that my objective is that this can be replicated by any user who has only been using Linux for a few days, waiting for solutions of the graphic type, copy and paste, avoiding complicated commands and the use of super user as much as possible.
Although for me it was more than copy and paste, it was a bit frustrating at first but seeing the result was worth it.
I will publish the tutorial in the “sound” sector, I think it would be more coherent like that, and I will leave a link to this same thread in case someone wants to venture into systemd XD.
-a script that watches the suspension of pulseaudio “ready”
-a script that updates the vigilant every X time “ready”
-a script that avoids a clone of the process, to avoid consumption of ram and cpu incesesary “ready”
-that it executes itself when starting the section or when the system is rebooted “ready”
The problem with the “graphic” solution is that you need to describe in detail what a user needs to do. If you use pictures is only works for XFCE or Gnome or KDE or some other DE. Since the UI changes a lot, it is very fast outdate. Plus you need to trust a user it will do the correct things.
A systemd user service solution, requires 2 files to be downloaded and 4 commands to set it up. The commands can be copy and pasted in the terminal. It does not get any easier. ( 2 commands to copy the script and the systemd user service file to the correct place and two commands to reload the systemd daemon and enable the service).
In Linux the terminal is a big part. A user that does not want to get in touch with it, is usually very fast back to a different OS.
@xabbu I had not thought about the other graphic environments, and you are right, it would be unintuitive for them, in addition to the possible obsolescence of my method.
After a few minutes thinking I decided to make it work within systemd-service, anyway I think it will be one more step after the whole journey.
I already have disabled everything that had been working until now, and I file it in a corner.
let’s go back to systemd
I currently have this in
[Unit] Description="Mute on idle" [Service] Type=simple User=jhonatan ExecStart=/home/jhonatan/.local/bin/call-to-mute [Install] WantedBy=multi-user.target
inside the directory
#!/bin/bash while [ true ] do /home/jhonatan/.local/bin/mute-on-idle sleep 0.5 done
inside the directory
#!/bin/bash state=$(pacmd list-sinks | grep -o RUNNING) if [[ $state == *"RUNNING"* ]];then pactl set-sink-mute 0 0 else pactl set-sink-mute 0 1 fi
-mute-on-idle.service “it works”
-call-to-mute “it works”
-mute-on-idle “it does not work”
I do not understand why this happens, I already did tests by terminal and it should work without problems
systemctl status mute-on-idle
● mute-on-idle.service - “Mute on idle”
Loaded: loaded (/etc/systemd/system/mute-on-idle.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2021-02-17 22:07:55 CET; 21min ago
Main PID: 650 (call-to-mute)
Tasks: 2 (limit: 9416)
├─ 650 /bin/bash /home/jhonatan/.local/bin/call-to-mute
└─17201 sleep 0.5
feb 17 22:29:19 corporacion-latitudee5540 call-to-mute: El demonio PulseAudio no está ejecutándose, o no se está ejecutando com> feb 17 22:29:19 corporacion-latitudee5540 call-to-mute: Error en la conexión: Conexión negada feb 17 22:29:19 corporacion-latitudee5540 call-to-mute: pa_context_connect() falló: Conexión negada feb 17 22:29:20 corporacion-latitudee5540 call-to-mute: El demonio PulseAudio no está ejecutándose, o no se está ejecutando com> feb 17 22:29:20 corporacion-latitudee5540 call-to-mute: Error en la conexión: Conexión negada feb 17 22:29:20 corporacion-latitudee5540 call-to-mute: pa_context_connect() falló: Conexión negada feb 17 22:29:21 corporacion-latitudee5540 call-to-mute: El demonio PulseAudio no está ejecutándose, o no se está ejecutando com> feb 17 22:29:21 corporacion-latitudee5540 call-to-mute: Error en la conexión: Conexión negada feb 17 22:29:21 corporacion-latitudee5540 call-to-mute: pa_context_connect() falló: Conexión negada feb 17 22:29:21 corporacion-latitudee5540 call-to-mute: El demonio PulseAudio no está ejecutándose, o no se está ejecutando com
I don’t know if pulseaudio has something to do with the malfunction
This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.