Fixed a small bug in the update notification script and how it was launched.

This commit is contained in:
Storm Dragon
2026-05-16 19:33:22 -04:00
parent 1b95555007
commit 7ef49290ea
2 changed files with 25 additions and 1 deletions
+1 -1
View File
@@ -1309,7 +1309,7 @@ if command -v waytray-daemon &> /dev/null ; then
fi
echo "exec_always --no-startup-id ${i3Path}/scripts/i38-clipboard.py --daemon"
echo "exec_always --no-startup-id ${i3Path}/scripts/desktop.sh"
echo "exec --no-startup-id ${i3Path}/scripts/i38-update-check.sh"
echo "exec_always --no-startup-id ${i3Path}/scripts/i38-update-check.sh"
if [[ $dex -eq 0 ]]; then
echo '# Start XDG autostart .desktop files using dex. See also'
echo '# https://wiki.archlinux.org/index.php/XDG_Autostart'
+24
View File
@@ -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