Sample Header Ad - 728x90

toggle a program using bash script

3 votes
3 answers
1985 views
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?
Asked by Galilean (574 rep)
Jun 14, 2019, 04:33 PM
Last activity: Feb 23, 2023, 12:37 PM