From 1cb78494f3022fe9d808d070507bddf552c64753 Mon Sep 17 00:00:00 2001 From: Casper Date: Wed, 18 Dec 2024 15:21:28 -0700 Subject: Initial commit, new repo --- scripts/qubes-i3-sensible-terminal | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 scripts/qubes-i3-sensible-terminal (limited to 'scripts/qubes-i3-sensible-terminal') diff --git a/scripts/qubes-i3-sensible-terminal b/scripts/qubes-i3-sensible-terminal new file mode 100644 index 0000000..5311dc1 --- /dev/null +++ b/scripts/qubes-i3-sensible-terminal @@ -0,0 +1,35 @@ +#!/usr/bin/bash +# Slightly modified from original to prioritize xfce4-terminal and st + +run_terminal=' +for t in "$TERMINAL" xfce4-terminal st x-terminal-emulator urxvt rxvt termit terminator Eterm aterm gnome-terminal konsole roxterm termite lxterminal mate-terminal terminology xterm; do + command -v "$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 + if command -v qrexec-client >/dev/null; then + qrexec-client -e -d "$vm" DEFAULT:"bash -c '$run_terminal'" + else + qvm-run "$vm" qvm-run "$vm" "bash -c '$run_terminal'" + fi + else # run terminal in dom0 + exec bash -c "$run_terminal" + fi +} + +main -- cgit v1.2.3