20 lines
594 B
Bash
Executable File
20 lines
594 B
Bash
Executable File
#!/bin/bash
|
|
# Freeze / resume the focused window's process tree (SIGSTOP / SIGCONT).
|
|
pid=$(xdotool getactivewindow getwindowpid 2>/dev/null) || exit 1
|
|
|
|
# collect pid plus all descendants (Wine/Proton games spawn several)
|
|
descendants() {
|
|
local p
|
|
for p in $(pgrep -P "$1"); do
|
|
echo "$p"
|
|
descendants "$p"
|
|
done
|
|
}
|
|
pids="$pid $(descendants "$pid")"
|
|
name=$(ps -o comm= -p "$pid")
|
|
|
|
case "$(ps -o state= -p "$pid")" in
|
|
T*) kill -CONT $pids && notify-send -t 1500 "Resumed" "$name ($pid)" ;;
|
|
*) kill -STOP $pids && notify-send -t 1500 "Frozen" "$name ($pid)" ;;
|
|
esac
|