Background gvfs restart to avoid blocking user.slice thaw

The post-sleep hook runs before systemd thaws user.slice, so a
synchronous systemctl --user restart hangs for ~90 seconds waiting
for the frozen user manager to respond — blocking the entire resume.

Background the restart with a short delay so it executes after
user.slice is thawed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Alan Sikora
2026-03-08 23:14:40 -03:00
co-authored by Claude Opus 4.6
parent a89c4f849d
commit e490ca7d78
+14 -9
View File
@@ -14,13 +14,18 @@ if [[ $1 == "pre" ]]; then
fi
if [[ $1 == "post" ]]; then
for uid_dir in /run/user/*; do
uid=$(basename "$uid_dir")
if [[ -S $uid_dir/bus ]]; then
sudo -u "#$uid" \
DBUS_SESSION_BUS_ADDRESS="unix:path=$uid_dir/bus" \
XDG_RUNTIME_DIR="$uid_dir" \
systemctl --user restart gvfs-daemon.service 2>/dev/null || true
fi
done
# Run in background — user.slice is still frozen at this point, so a
# synchronous restart would block the thaw for up to 90 seconds.
(
sleep 5
for uid_dir in /run/user/*; do
uid=$(basename "$uid_dir")
if [[ -S $uid_dir/bus ]]; then
sudo -u "#$uid" \
DBUS_SESSION_BUS_ADDRESS="unix:path=$uid_dir/bus" \
XDG_RUNTIME_DIR="$uid_dir" \
systemctl --user restart gvfs-daemon.service 2>/dev/null || true
fi
done
) &
fi