Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
myscope=$(cat /proc/$PPID/cgroup | rev | cut -d/ -f1 | rev);
swaymsg -m -t subscribe '["window"]' \
| jq '.container.pid' \
| (while read pid; do cat /proc/$pid/cgroup | cut -d: -f3- ; done) \
| (rev | cut -d '/' -f1 | rev | grep -E '^run-[[:alnum:]].*\.scope$') \
| (
last="";
while read scope; do
if [ ! -z "$last" ] && [ "$last" != "$myscope" ]; then
printf "exiting %s, freezing\n" "$last";
(set -x; systemctl kill --user --signal STOP "$last");
fi ;
(set -x; systemctl kill --user --signal CONT "$scope");
last="$scope";
done
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.