Page MenuHomeFreeBSD
Paste P585

/usr/local/sbin/suspend.sh
ActivePublic

Authored by grahamperrin on Jun 23 2023, 6:47 PM.
Tags
None
Referenced Files
F63231077: /usr/local/sbin/suspend.sh
Jun 23 2023, 6:49 PM
F63231007: /usr/local/sbin/suspend.sh
Jun 23 2023, 6:47 PM
Subscribers
None
#!/bin/sh
# Save this script at a suitable path, for example
# /usr/local/sbin/suspend.sh
# then edit /etc/rc.suspend to include the path.
# Allow detachment of a USB device that is used for a ZFS pool named
# Transcend.
#
while mount | grep Transcend 2>&1; do
zpool export Transcend
sleep 5
done
# Since <https://bugs.freebsd.org/253553> is fixed, I wonder whether combined
# use of sysutils/lsof lsof(8) and devel/libnotify notify-send(1) can notify
# the user of the path to an open file, if one is open within the pool.
# <https://www.freebsd.org/cgi/man.cgi?query=lsof&sektion=8&manpath=freebsd-ports>
# <https://www.freebsd.org/cgi/man.cgi?query=notify-send&sektion=1&manpath=freebsd-ports>
# Allow detachment of USB devices that are used for OpenZFS L2ARC for
# the boot pool on internal storage.
#
zpool offline august gpt/cache-august
zpool offline august gpt/cache2-august
zpool offline august gpt/cache3-august
sync
killall pulseaudio
# Credit to David Schlachter for 'USB audio devices on FreeBSD'
# <https://www.davidschlachter.com/misc/freebsd-usb-audio>
#
# Attempt to kill all dsp- and mixer-related processes.
#
while fstat | grep -e dsp -e mixer 2>&1; do
fstat | grep -e dsp -e mixer | cut -w -f 3 | while read pid;
do kill -15 "$pid"
done
done
# Make <IDT 92HD81B1X (Analog 2.0+HP/2.0)> (play/rec) the default
# on an HP EliteBook 8570p.
#
sysctl hw.snd.default_unit=1
# Retrospective
# =============
#
# I found it impossible to kill PulseAudio. Instead, it was set to no longer
# automatically spawn: <https://forums.FreeBSD.org/posts/519408>.
#
# Killing of KMix by the script required a manual run of
# /usr/local/bin/kded5 &
# as grahamperrin after each wake of the computer.
#
# For a while, I forced deletion of KMix –
# <https://forums.FreeBSD.org/posts/524012> – and used a fake manifest to
# prevent automated reinstallation: <https://forums.FreeBSD.org/posts/528187>.
#
# Eventually, the issue involving KMix was resolved:
# <https://github.com/freebsd/freebsd-ports/commit/7dc8045a63930a3a520e17723139003867b58c39>

Event Timeline

grahamperrin created this object in space S1 Global.
grahamperrin edited the content of this paste. (Show Details)