@@ -13,24 +13,33 @@ export ELECTRON_OZONE_PLATFORM_HINT=wayland
1313
1414bindir=$( CDPATH= cd -- " $( dirname -- " $0 " ) " && pwd)
1515
16- # 1. Define a cleanup function to fix the TTY for 'ly'
16+ # 1. Force-kill any lingering background processes from previous dead sessions
17+ # (This ensures you always start with a clean state and your real audio device)
18+ killall -q pipewire wireplumber pipewire-pulse swaync 2> /dev/null || true
19+
20+ # 2. Define a cleanup function to fix the TTY for 'ly' and clean up processes
1721cleanup () {
1822 # Disable exit-on-error for the cleanup phase
1923 set +e
24+
25+ # Kill the current session's background processes on logout
26+ killall -q pipewire wireplumber pipewire-pulse swaync 2> /dev/null || true
27+ killall -9 Xwayland
28+
2029 # Give seatd/elogind a split-second to release the DRM/Input devices
2130 sleep 0.5
2231 # Restore terminal properties
2332 stty sane
2433 # Attempt to pull keyboard out of raw mode (suppress errors if run as non-root)
25- kbd_mode -a 2> /dev/null
34+ kbd_mode -a 2> /dev/null || true
2635 # Completely reset the TTY
2736 reset
2837}
2938
30- # 2 . Trap the script exit so the cleanup ALWAYS runs, even if Sway crashes
39+ # 3 . Trap the script exit so the cleanup ALWAYS runs, even if Sway crashes
3140trap cleanup EXIT INT TERM
3241
33- # 3 . Launch Sway wrapped inside a dedicated D-Bus session
42+ # 4 . Launch Sway wrapped inside a dedicated D-Bus session
3443if [ -x " $bindir /swayfx" ]; then
3544 dbus-run-session " $bindir /swayfx" " $@ "
3645else
0 commit comments