#!/usr/bin/python3 -Bsu

## Copyright (C) 2019 - 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
## See the file COPYING for copying conditions.

## https://forums.whonix.org/t/send-sysrq-commands-to-virtualbox-usability-helper-virtualbox-send-sysrq/8369

## Shell-invocation guard.
"exec" "bash" "-c" "printf '%s\n' '$0: ERROR: Do not execute this script with bash!' >&2; exit 1"

import subprocess
import sys

vmname = sys.argv[1]
key = sys.argv[2]

subprocess.call(['VBoxManage', 'controlvm', vmname, 'keyboardputscancode', '1d', '38', '54'])
subprocess.call(['VBoxManage', 'controlvm', vmname, 'keyboardputstring', key])
subprocess.call(['VBoxManage', 'controlvm', vmname, 'keyboardputscancode', 'd4', 'b8', '9d'])
