Fixed a small bug in the update notification script and how it was launched.
This commit is contained in:
@@ -21,6 +21,8 @@ i3Dir="$(dirname -- "$scriptDir")"
|
||||
versionFile="${I38_VERSION_FILE:-${i3Dir}/i38-version}"
|
||||
stateDir="${XDG_STATE_HOME:-${HOME}/.local/state}/I38"
|
||||
notifyState="${stateDir}/update-check-notified"
|
||||
runtimeDir="${XDG_RUNTIME_DIR:-/tmp}"
|
||||
lockDir="${runtimeDir}/i38-update-check"
|
||||
|
||||
valid_commit() {
|
||||
[[ "${1:-}" =~ ^[0-9a-fA-F]{40}$ ]]
|
||||
@@ -84,10 +86,32 @@ send_update_notification() {
|
||||
remember_notification "$remoteCommit"
|
||||
}
|
||||
|
||||
stop_update_check() {
|
||||
rm -rf "$lockDir"
|
||||
exit 0
|
||||
}
|
||||
|
||||
if ! command -v git > /dev/null || ! command -v notify-send > /dev/null; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ -d "$lockDir" ]]; then
|
||||
if [[ -f "${lockDir}/pid" ]]; then
|
||||
IFS= read -r existingPid < "${lockDir}/pid" || existingPid=""
|
||||
if [[ "$existingPid" =~ ^[0-9]+$ ]] && kill -0 "$existingPid" 2> /dev/null; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
rm -rf "$lockDir"
|
||||
fi
|
||||
|
||||
if ! mkdir "$lockDir" 2> /dev/null; then
|
||||
exit 0
|
||||
fi
|
||||
printf '%s\n' "$$" > "${lockDir}/pid"
|
||||
trap 'rm -rf "$lockDir"' EXIT
|
||||
trap stop_update_check INT TERM
|
||||
|
||||
sleep "$initialDelay"
|
||||
|
||||
while :; do
|
||||
|
||||
Reference in New Issue
Block a user