Skip to content

Instantly share code, notes, and snippets.

@SietsevanderMolen
Last active May 8, 2024 12:43
Show Gist options
  • Save SietsevanderMolen/7c6f2b5773dbc0c08e1509e49abd1e96 to your computer and use it in GitHub Desktop.
Save SietsevanderMolen/7c6f2b5773dbc0c08e1509e49abd1e96 to your computer and use it in GitHub Desktop.
Opens a terminal in the domain belonging to the current active winow
#!/bin/bash
run_terminal='
for t in $TERMINAL urxvt rxvt terminator Eterm aterm xterm gnome-terminal roxterm xfce4-terminal; do
which $t > /dev/null 2>&1 && exec $t;
done
'
get_id() {
local id=$(xprop -root _NET_ACTIVE_WINDOW)
echo ${id##* } # extract id
}
get_vm() {
local id=$(get_id)
local vm=$(xprop -id $id | grep '_QUBES_VMNAME(STRING)')
local vm=${vm#*\"} # extract vmname
echo ${vm%\"*} # extract vmname
}
main() {
local vm=$(get_vm)
if [[ -n "$vm" ]]; then
qvm-run "$vm" "bash -c '$run_terminal'"
else # run terminal in dom0
exec bash -c "$run_terminal"
fi
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment