Last active
December 21, 2016 18:22
-
-
Save jpouellet/d57fb4e98ca3f5ad4ac0ec2596d18154 to your computer and use it in GitHub Desktop.
Shuts down the focused VM in Qubes
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
#!/bin/sh | |
# PROBLEM: Allows the front VM to close its focused window right before | |
# keystroke delivery, leading to shutting down the VM with the window in | |
# back. Effective denial of service. | |
set -e | |
front=$(xprop -notype -root _NET_ACTIVE_WINDOW | awk '{if (match($0,"^_NET_ACTIVE_WINDOW: window id # (0x[0-9a-f]*), 0x0$",m)){print m[1];} exit 0;}' ) | |
test -n "$front" | |
vm=$(xprop -id "$front" -notype _QUBES_VMNAME | awk '{if (match($0,"^_QUBES_VMNAME = \"([^\"]*)\"$",m)){print m[1];} exit 0;}') | |
test -n "$vm" | |
exec qvm-shutdown -- "$vm" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oops, pasted wrong script initially >_>