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:
co-authored by
Claude Opus 4.6
parent
a89c4f849d
commit
e490ca7d78
@@ -14,13 +14,18 @@ if [[ $1 == "pre" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $1 == "post" ]]; then
|
if [[ $1 == "post" ]]; then
|
||||||
for uid_dir in /run/user/*; do
|
# Run in background — user.slice is still frozen at this point, so a
|
||||||
uid=$(basename "$uid_dir")
|
# synchronous restart would block the thaw for up to 90 seconds.
|
||||||
if [[ -S $uid_dir/bus ]]; then
|
(
|
||||||
sudo -u "#$uid" \
|
sleep 5
|
||||||
DBUS_SESSION_BUS_ADDRESS="unix:path=$uid_dir/bus" \
|
for uid_dir in /run/user/*; do
|
||||||
XDG_RUNTIME_DIR="$uid_dir" \
|
uid=$(basename "$uid_dir")
|
||||||
systemctl --user restart gvfs-daemon.service 2>/dev/null || true
|
if [[ -S $uid_dir/bus ]]; then
|
||||||
fi
|
sudo -u "#$uid" \
|
||||||
done
|
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
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user