Jocelyn Le Sage e1d32c30f2 Improved graceful shutdown of Firefox:
- By default, disable confirmation when quitting using the ctrl+q shortcut.
  - Wait for Firefox to quit after sending ctrl+q key presses.
2023-04-08 21:55:36 -04:00

26 lines
530 B
Bash
Executable File

#!/bin/sh
#
# Firefox doesn't gracefully shutdown when receiving SIGTERM. For example, last
# opened tabs may not be saved. Instead, terminate Firefox by sending the
# CTRL+q key presses.
#
set -e # Exit immediately if a command exits with a non-zero status.
set -u # Treat unset variables as an error.
xdotool key "Escape"
sleep 0.5
xdotool key "ctrl+q"
for i in $(seq 1 10)
do
if ! ps | grep "/usr/lib/firefox/firefox" | grep -q -v grep
then
break
fi
sleep 0.5
done
# vim:ft=sh:ts=4:sw=4:et:sts=4