I am trying to make a script that will toggle redshift
(a night mode application). So, I've done this,
#!/bin/bash pgrep redshift > /dev/null && \ killall redshift || \ setsid redshift [options] &> /dev/null
This looks up for the program and if that program is running in the background then it is killed otherwise it is started and is setsid
. Now, this script works if I am to kill the process, but this script hangs when I run it back.
- What am I doing wrong?
- Is there other ways to put the process background so that killing the terminal won't stop the program?
pgrep redshift > /dev/null && ...