Last active
May 18, 2020 01:04
-
-
Save grahamc/2b81e7d989dfa2c563001f31d55e2c53 to your computer and use it in GitHub Desktop.
This file contains 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
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