Skip to content

Instantly share code, notes, and snippets.

@grahamc
Last active May 18, 2020 01:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grahamc/2b81e7d989dfa2c563001f31d55e2c53 to your computer and use it in GitHub Desktop.
Save grahamc/2b81e7d989dfa2c563001f31d55e2c53 to your computer and use it in GitHub Desktop.
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