ls -l /home/jhonatan/Documents/mute-call ls: '/ home/jhonatan/Documents/mute-call' cannot be accessed: File or directory does not exist
what I have inside the script is this: #!/bin/bash watch -n0,5 /home/jhonatan/Documentos/mute-on-idle-jcc2 command &
I don’t know if I have to rename the script or change something inside
Okay, I had a slightly crooked route.
the correct path is: ls -l /home/jhonatan/Documentos/call-mute -rwxr-xr-x 1 jhonatan jhonatan 77 feb 16 15:29 /home/jhonatan/Documentos/call-mute
and the output of satus is:
● mute-on-idle.service - Mute idle
Loaded: loaded (/etc/systemd/system/mute-on-idle.service; disabled; vendor preset: disabled)
Active: failed (Result: start-limit-hit) since Tue 2021-02-16 16:48:23 CET; 7min ago
Process: 314880 ExecStart=/home/jhonatan/Documentos/call-mute (code=exited, status=0/SUCCESS)
Main PID: 314880 (code=exited, status=0/SUCCESS)
feb 16 16:48:23 corporacion-latitudee5540 systemd[1]: mute-on-idle.service: Scheduled restart job, restart counter is at 5.
feb 16 16:48:23 corporacion-latitudee5540 systemd[1]: Stopped Mute idle.
feb 16 16:48:23 corporacion-latitudee5540 systemd[1]: mute-on-idle.service: Start request repeated too quickly.
feb 16 16:48:23 corporacion-latitudee5540 systemd[1]: mute-on-idle.service: Failed with result 'start-limit-hit'.
feb 16 16:48:23 corporacion-latitudee5540 systemd[1]: Failed to start Mute idle.
I have removed the background execution and get this:
● mute-on-idle.service - Mute idle
Loaded: loaded (/etc/systemd/system/mute-on-idle.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Tue 2021-02-16 17:02:18 CET; 4s ago
Process: 316040 ExecStart=/home/jhonatan/Documentos/call-mute (code=exited, status=1/FAILURE)
Main PID: 316040 (code=exited, status=1/FAILURE)
feb 16 17:02:18 corporacion-latitudee5540 systemd[1]: mute-on-idle.service: Scheduled restart job, restart counter is at 5.
feb 16 17:02:18 corporacion-latitudee5540 systemd[1]: Stopped Mute idle.
feb 16 17:02:18 corporacion-latitudee5540 systemd[1]: mute-on-idle.service: Start request repeated too quickly.
feb 16 17:02:18 corporacion-latitudee5540 systemd[1]: mute-on-idle.service: Failed with result 'exit-code'.
feb 16 17:02:18 corporacion-latitudee5540 systemd[1]: Failed to start Mute idle.
~
why not use a systemd timer and call only /home/jhonatan/Documentos/mute-on-idle-jcc2 command ???
ps: test before alone script mute-on-idle-jcc2 - mute-on-idle-jcc2 command ? parameter is “command” ???
Every half second isn’t very practicable for a timer.
But I think OP need to rethink the approach. It looks like watch can’t be used in a systemd service. It requires a terminal. (A workaround might be using screen or temux)
there is a persistent “shhhhhh” in my headphones, I already checked with: watch pacmd list-sinks
and pulseaudio works fine.
Here is the link to my publication in the sound section:
So I created my own script to automate the silence, I have no programming idea, I never wrote a script or something like that, after two days of research, trial and error I have this:
I’m going to call the main engine script:
#!/bin/bash
state=$(pacmd list-sinks | grep RUNNING | grep -o RUNNING)
if [[ $state == *"RUNNING"* ]];then
pactl set-sink-mute 0 0
else
pactl set-sink-mute 0 1
fi
I call the second script the power button: #!/bin/bash watch -n0,5 /home/jhonatan/Documentos/mute-on-idle-jcc2
and finally the service:
[Unit]
Description=Mute on idle
So basically, you want a script that starts a script every half a second.
Could be done in one script, but doesn’t matter. Do not use watch , use a infinite loop. It can be a while or even a for loop. At a sleep command to pause for a specific time.
for example
#!/bin/bash
while [ true ]
do
/home/jhonatan/Documentos/mute-on-idle-jcc2
sleep 0.5
done
Of course you could put the content of /home/jhonatan/Documentos/mute-on-idle-jcc2 into the while loop. Then start it with the systemd service.
I quite like the result, I just want to solve a problem.
How do I hide the window of the terminal started by the script?
if we close it manually the process is dead.
So is there a way to hide the window and keep the process alive?
Yes, I used it, and it goes very well, your script gave a better direction to my construction.
well, I think we could close the issue, service is working and the scripts work as expected.
I am going to mark the answer that made the service work as a solution.
Thank you very much for your time to: @xabbu@papajoke@Mirdarthos