diff options
Diffstat (limited to 'sh/dyafk')
-rwxr-xr-x | sh/dyafk | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -8,11 +8,17 @@ while :; do if [ "$(curl -s https://www.douyu.com/betard/9640128 | jq '.room.show_status')" -eq 1 ]; then if ! pidof -q firefox; then firefox --headless --profile "$HOME/.mozilla/firefox/dyafk" https://www.douyu.com/9640128 & + # assign previous background process to pid variable + pid=$! fi else - if pidof -q firefox; then - kill $(pidof firefox) 2>/dev/null - # for logging, so I know when firefox killed, which also need that `if pidof -q firefox` + if [ "$pid" ]; then + # seems need to only SIGTERM kill the parent firefox process, else firefox will prompt me firefox closed unexpectedly warning which cause firefox not actually open the url + # https://www.reddit.com/r/firefox/comments/fq1mhi/kill_firefox_gracefully_via_terminal_headless/ + # firefox seems now can handle SIGTERM on linux? https://bugzilla.mozilla.org/show_bug.cgi?id=1837907 + kill "$pid" + pid= + # for logging, I want to know when firefox killed echo 'kill firefox' fi fi |