Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Show comment
Hide comment
@jpouellet

jpouellet Dec 21, 2016

Oops, pasted wrong script initially >_>

Owner

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