Hello,
Could someone possibly help me out with this please. I'm trying to write a script to completely restart/reload my web browser (Brave in this instance) when I run it. I'm using a script to load Strawberry music player after shutting down the Pulse audio service and masking the Pulse audio socket.
systemctl --user mask pulseaudio.socket
systemctl --user stop pulseaudio.service
/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=strawberry --file-forwarding org.strawberrymusicplayer.strawberry @@u %U @@
This then ensures that the sound output is via ALSA alone to my DAC. The problem is that after closing Strawberry and running another script to reverse the affect on Pulse I have no sound output from Brave until I completely close and reopen it. The restart of Pulse works as intended but Brave isn't restarting. I've tried 'restart' and 'reload' but all it seems to do is restart the service only which doesn't give me my audio back.
systemctl --user unmask pulseaudio.socket
systemctl --user start pulseaudio.service
systemctl reload brave
It never dawned on me but I just thought of something whilst typing. Would I need to 'kill' Brave and restart via the script in order for this to work? I don't know, I'm new to all this. Any help would be greatly appreciated.
Restart/Reload a program with bash.[SOLVED]
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Topics in this forum are automatically closed 6 months after creation.
Restart/Reload a program with bash.[SOLVED]
Last edited by Tav on Wed Mar 20, 2024 6:20 pm, edited 1 time in total.
Re: Restart/Reload a program with bash.
systemctl manages system and user services. Brave is an app so you can't manage it with systemctl. Some apps have command line option to do things like reload the configuration without quitting the app. Brave doesn't as far as I saw: https://support.brave.com/hc/en-us/arti ... s-in-Brave. It would anyway not help in this case as making the app use a different sound server probably still needs quitting the app.
Probably you can use the command
Probably you can use the command
killall brave
to kill all Brave windows. Then restart it. Looks like a lot but use command nohup setsid --fork brave >/dev/null
to start Brave from the script. That completely disconnects Brave from the shell and terminal (for when you're trying out your script) which will avoid some nuisances.Re: Restart/Reload a program with bash.
Thanks for the reply, I appreciate it. I just tried it but Brave locked up. I had to force quit. When you say other apps have a command line option for certain things would that include Firefox? I'm not adverse to switching back to make this work.
I was wondering actually if Brave could be started in the same way as the script for Strawberry? Although it seems it was the killall command that caused the lockup so if it won't shutdown properly then it isn't going to restart...
I was wondering actually if Brave could be started in the same way as the script for Strawberry? Although it seems it was the killall command that caused the lockup so if it won't shutdown properly then it isn't going to restart...
Re: Restart/Reload a program with bash.
@xenopeek. Okay, so I switched back to Firefox and ran the same commands you gave me. It worked, in essence. It didn't close the running instance of Firefox but opened another window along side it. But, the sound on the already open instance came straight back.
I'm happy with that thank you. It involves closing a newly opened window which is really only one click away from manually closing the browser and reopening it but what I really wanted was to ensure Pulse wasn't influencing my sound output when playing music and I've achieved that.
I'm happy with that thank you. It involves closing a newly opened window which is really only one click away from manually closing the browser and reopening it but what I really wanted was to ensure Pulse wasn't influencing my sound output when playing music and I've achieved that.