Created
March 8, 2025 12:52
-
-
Save wastee/dcbe17ddc8cadc0da149077f3c99fac6 to your computer and use it in GitHub Desktop.
Terminate the WINE process when REAPER exits.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Desktop Entry] | |
Encoding=UTF-8 | |
Type=Application | |
Name=REAPER | |
Comment=REAPER | |
Categories=Audio;Video;AudioVideo;AudioVideoEditing;Recorder; | |
#Exec="/usr/lib/REAPER/reaper" %F | |
Exec=/home/tee/.local/bin/reaper-killer %F | |
Icon=cockos-reaper | |
MimeType=application/x-reaper-project;application/x-reaper-project-backup;application/x-reaper-theme | |
StartupWMClass=REAPER |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 启动REAPER并等待退出 | |
/usr/lib/REAPER/reaper "$@" | |
# 定义 Bottles 目录路径 | |
BOTTLES_DIR="$HOME/.local/share/bottles/bottles" | |
# --------------------------- | |
# 步骤 1: 快速关闭所有 Wine 前缀 | |
# --------------------------- | |
echo "快速终止 Wine 服务..." | |
for prefix in "$BOTTLES_DIR"/*/; do | |
if [[ -d "$prefix" ]]; then | |
WINEPREFIX="$prefix" wineserver -k & # 后台并行执行 | |
fi | |
done | |
wait # 等待所有 wineserver 完成 | |
# --------------------------- | |
# 步骤 2: 暴力清理残留进程(极速版) | |
# --------------------------- | |
echo "极速清理残留进程..." | |
# 预过滤可能关联 Wine 的进程(如 wine*, .exe, explorer.exe 等) | |
pgrep -f '\.exe' | while read -r pid; do | |
# 快速提取 WINEPREFIX(跳过无权限访问的进程) | |
wineprefix=$(strings "/proc/$pid/environ" 2>/dev/null | grep -m1 '^WINEPREFIX=' | cut -d= -f2-) | |
# 若 WINEPREFIX 在目标路径下,直接强制终止 | |
if [[ -n "$wineprefix" && "$wineprefix" == "$BOTTLES_DIR"* ]]; then | |
kill -9 "$pid" 2>/dev/null && echo "已强制终止进程 $pid" | |
fi | |
done | |
echo "操作完成。" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please modify the path to match your environment and grant execute permissions to the
reaper-killer
script.If your REAPER binary is not located at /usr/lib/REAPER/reaper, update the path to match your REAPER installation's location.