On mac, the open binary can be used to launch an application. I'm not sure if this exists in other environments. The below will check if Spotify is running and if it is, it echos "Running", but if it isn't it launches Spotify. The next step is to include the kill command if Spotify is already running instead of the echo.
#!/bin/bash
PROCESS=spotify
number=$(ps aux | grep -v grep | grep -ci $PROCESS)
if [ $number -gt 0 ]
then
echo Running;
else
open -a Spotify;
fi
I found your idea interesting and spent a little bit working on part of it. The below snippet successfully checks if Spotify is running and reports "Running" or "not running" depending. This could be modified to launch or kill Spotify instead of echoing the status.
#!/bin/bash
PROCESS=spotify
number=$(ps aux | grep -v grep | grep -ci $PROCESS)
if [ $number -gt 0 ]
then
echo Running;
else
echo not running;
fi
Including a kill statement might look something like:
On mac, the open binary can be used to launch an application. I'm not sure if this exists in other environments. The below will check if Spotify is running and if it is, it echos "Running", but if it isn't it launches Spotify. The next step is to include the kill command if Spotify is already running instead of the echo.
I found your idea interesting and spent a little bit working on part of it. The below snippet successfully checks if Spotify is running and reports "Running" or "not running" depending. This could be modified to launch or kill Spotify instead of echoing the status.
Thought I was on /r/PowerWashingPorn for a minute
And then they get a GDPR right to be forgotten removal request and have to dig the whole thing back up?
And on your cake day and everything!
https://xkcd.com/378/
Happy cake day!
Good to know! Thanks for the update.
My being away from arch for the last year or so is showing.
--force --no-confirm
Used those when trying to install new gpu drivers... Forgot to specify which version... many lessons were learned that day.
End of this list.
Back to top