diff --git a/default/systemd/system-sleep/unmount-fuse b/default/systemd/system-sleep/unmount-fuse new file mode 100755 index 00000000..54a4206d --- /dev/null +++ b/default/systemd/system-sleep/unmount-fuse @@ -0,0 +1,33 @@ +#!/bin/bash + +# Lazy-unmount gvfsd-fuse filesystems before suspend/hibernate to prevent the +# kernel's process freeze from timing out. FUSE daemons (like gvfsd-fuse from +# Nautilus) can block in uninterruptible sleep during freeze, causing suspend +# to silently fail. After wake, restart gvfs so the FUSE mount is restored. + +if [[ $1 == "pre" ]]; then + while IFS=' ' read -r _ mountpoint fstype _; do + if [[ $fstype == fuse.gvfsd-fuse ]]; then + mountpoint=$(printf '%b' "$mountpoint") + fusermount3 -uz "$mountpoint" 2>/dev/null || fusermount -uz "$mountpoint" 2>/dev/null || true + fi + done < /proc/mounts +fi + +if [[ $1 == "post" ]]; then + # 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" env \ + 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 + ) & + disown +fi diff --git a/install/config/all.sh b/install/config/all.sh index c12ffc64..f45f09cb 100644 --- a/install/config/all.sh +++ b/install/config/all.sh @@ -18,6 +18,7 @@ run_logged $OMARCHY_INSTALL/config/remove-fcitx5-autostart.sh run_logged $OMARCHY_INSTALL/config/localdb.sh run_logged $OMARCHY_INSTALL/config/walker-elephant.sh run_logged $OMARCHY_INSTALL/config/fast-shutdown.sh +run_logged $OMARCHY_INSTALL/config/unmount-fuse.sh run_logged $OMARCHY_INSTALL/config/sudoless-asdcontrol.sh run_logged $OMARCHY_INSTALL/config/input-group.sh run_logged $OMARCHY_INSTALL/config/omarchy-ai-skill.sh diff --git a/install/config/unmount-fuse.sh b/install/config/unmount-fuse.sh new file mode 100644 index 00000000..9c44e17f --- /dev/null +++ b/install/config/unmount-fuse.sh @@ -0,0 +1,2 @@ +sudo mkdir -p /usr/lib/systemd/system-sleep +sudo install -m 0755 -o root -g root "$OMARCHY_PATH/default/systemd/system-sleep/unmount-fuse" /usr/lib/systemd/system-sleep/ diff --git a/migrations/1773012889.sh b/migrations/1773012889.sh new file mode 100644 index 00000000..d8dd1619 --- /dev/null +++ b/migrations/1773012889.sh @@ -0,0 +1,4 @@ +echo "Install system-sleep hook to unmount gvfsd-fuse before suspend/hibernate" + +sudo mkdir -p /usr/lib/systemd/system-sleep +sudo install -m 0755 -o root -g root "$OMARCHY_PATH/default/systemd/system-sleep/unmount-fuse" /usr/lib/systemd/system-sleep/