Add the installer, uninstaller, and generated docs

This commit is contained in:
2026-09-20 00:19:38 -04:00
parent 0c422e7345
commit 3e65d176e3
100 changed files with 2585 additions and 0 deletions
+65
View File
@@ -0,0 +1,65 @@
#!/bin/bash
set -e
# Use the Vfio to Integrated trick to turn off NVIDIA dgpu when in integrated mode
# without needing to restart the computer. This is needed because computers like the Asus G14
# will wake after suspend in Hybrid mode, even if the system was in Integrated mode before
# suspending.
restore_marker=/run/blob-force-igpu-integrated
sleep_action=${SYSTEMD_SLEEP_ACTION:-$2}
[[ -x /usr/bin/supergfxctl ]] || exit 0
switch_mode() {
local expected="$1" current
if ! /usr/bin/timeout --kill-after=1s 3s /usr/bin/supergfxctl -m "$expected"; then
echo "Could not request the GPU transition to $expected mode" >&2
return 1
fi
for _ in {1..10}; do
if current=$(/usr/bin/timeout --kill-after=1s 2s /usr/bin/supergfxctl -g 2>/dev/null) &&
[[ $current == "$expected" ]]; then
return 0
fi
sleep 1
done
echo "Could not confirm the GPU transition to $expected mode" >&2
return 1
}
case "$1" in
pre)
# Remember the mode this sleep cycle started in. supergfxctl persists the
# temporary hibernate switch to Vfio, so post must not consult that mutable
# value when deciding whether to restore Integrated mode.
if [[ -L $restore_marker ]]; then
exit 1
elif [[ ! -f $restore_marker ]]; then
/usr/bin/grep -Eq '"mode"[[:space:]]*:[[:space:]]*"Integrated"' /etc/supergfxd.conf 2>/dev/null || exit 0
/usr/bin/install -m 0600 -o root -g root -T /dev/null "$restore_marker"
fi
# Before hibernating, switch to Vfio so the nvidia driver is detached from the dGPU.
# Without this, hibernate resume fails because the nvidia driver can't freeze a
# powered-off dGPU (returns -EIO), which aborts the entire resume.
if [[ $sleep_action == "hibernate" ]]; then
switch_mode Vfio
fi
;;
post)
[[ -f $restore_marker && ! -L $restore_marker ]] || exit 0
# small delay so the device is fully re-enumerated
sleep 4
# force-bind dGPU to vfio (fully detached from nvidia)
switch_mode Vfio
# then go back to Integrated, which powers it off again
switch_mode Integrated
/usr/bin/rm -f -- "$restore_marker"
;;
esac
@@ -0,0 +1,20 @@
#!/bin/bash
# Turn off keyboard backlight before hibernate to prevent hang on power-off.
# The ASUS keyboard controller can block S4 shutdown if LEDs are active.
sleep_action=${SYSTEMD_SLEEP_ACTION:-$2}
if [[ $1 == "pre" && $sleep_action == "hibernate" ]]; then
device=""
for candidate in /sys/class/leds/*kbd_backlight*; do
if [[ -e "$candidate" ]]; then
device="$(basename "$candidate")"
break
fi
done
if [[ -n "$device" ]]; then
brightnessctl -d "$device" set 0 >/dev/null 2>&1
fi
fi
+32
View File
@@ -0,0 +1,32 @@
#!/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
) &
fi