Skip to content

Instantly share code, notes, and snippets.

@jpouellet
Last active December 21, 2016 18:22
Show Gist options
  • Save jpouellet/d57fb4e98ca3f5ad4ac0ec2596d18154 to your computer and use it in GitHub Desktop.
Save jpouellet/d57fb4e98ca3f5ad4ac0ec2596d18154 to your computer and use it in GitHub Desktop.
Shuts down the focused VM in Qubes
#!/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"
@jpouellet
Copy link
Author

jpouellet commented Dec 21, 2016

Oops, pasted wrong script initially >_>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment