-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: better dom0 terminal usability
These helpers were in the dotfiles submodule, but they are very useful and makes sense to port them to this project, especially when in need to update Qusal. Fixes: #18 Fixes: #21
- Loading branch information
1 parent
85c822c
commit c5aaf1f
Showing
11 changed files
with
199 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/sh | ||
|
||
# SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <[email protected]> | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
## Copy a file from an DomU to Dom0. Script has to be run in Dom0 | ||
set -eu | ||
|
||
usage(){ | ||
echo "usage: ${0##*/} <QUBE> <FILE> <FILE2...> | ||
note: disk quota is capped and can be controlled via environment variables: | ||
note: UPDATES_MAX_BYTES (default: 4GiB) | ||
note: UPDATES_MAX_FILES (default: 2048)" >&2 | ||
exit 1 | ||
} | ||
|
||
test -n "${2-}" || usage | ||
qube="${1}" | ||
shift | ||
|
||
dir="${HOME}/QubesIncoming/${qube}" | ||
user="$(qvm-prefs --get -- "${qube}" default_user)" | ||
max_bytes="${UPDATES_MAX_BYTES:-4GiB}" | ||
max_files="${UPDATES_MAX_FILES:-2048}" | ||
qvm-run --pass-io --localcmd=" | ||
UPDATES_MAX_BYTES=\"${max_bytes}\" UPDATES_MAX_FILES=\"${max_files}\" | ||
/usr/libexec/qubes/qfile-dom0-unpacker \"${user}\" \"${dir}\"" \ | ||
"${qube}" /usr/lib/qubes/qfile-agent "${@}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
qvm-terminal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/sh | ||
|
||
# SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <[email protected]> | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
set -eu | ||
|
||
me="${0##*/}" | ||
|
||
usage(){ | ||
printf '%s\n' "Usage: ${me} [QVM-RUN_OPTIONS] QUBE | ||
Examples: | ||
${me} --dispvm=DVM_TEMPLATE | ||
${me} -u root QUBE | ||
${me} QUBE" >&2 | ||
exit "${1-"1"}" | ||
} | ||
|
||
case "${me}" in | ||
*-terminal) service=qubes-run-terminal ;; | ||
*-file-manager) service=qubes-open-file-manager ;; | ||
*) printf '%s\n' "Invalid script name: ${me}" exit 1 ;; | ||
esac | ||
|
||
|
||
case "${1-}" in | ||
-h|--help) | ||
usage 1 | ||
;; | ||
"") | ||
## Try to run on focused window, if Dom0 is focused, it will prompt you to | ||
## select a qube window. | ||
id="$(xdotool getwindowfocus)" | ||
qube="$(xprop -id "${id}" -notype _QUBES_VMNAME | awk -F '"' '{print $2}')" | ||
if test -n "${qube}"; then | ||
exec qvm-run --service -- "${qube}" "qubes.StartApp+${service}" | ||
fi | ||
echo "Select a qube window ..." | ||
id="$(xdotool selectwindow)" | ||
qube="$(xprop -id "${id}" -notype _QUBES_VMNAME | awk -F '"' '{print $2}')" | ||
if test -n "${qube}"; then | ||
qvm-run --service -- "${qube}" "qubes.StartApp+${service}" | ||
fi | ||
;; | ||
*) | ||
qvm-run --service "${@}" -- "qubes.StartApp+${service}" | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{# | ||
SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. <[email protected]> | ||
|
||
SPDX-License-Identifier: AGPL-3.0-or-later | ||
#} | ||
|
||
{% if grains['nodename'] == 'dom0' -%} | ||
|
||
"{{ slsdotpath }}-terminal-helper": | ||
file.managed: | ||
- name: /usr/local/bin/qvm-termnal | ||
- source: salt://{{ slsdotpath }}/files/bin/qvm-terminal | ||
- mode: "0755" | ||
- user: root | ||
- group: root | ||
- makedirs: True | ||
|
||
"{{ slsdotpath }}-file-manager-helper": | ||
file.symlink: | ||
- require: | ||
- file: "{{ slsdotpath }}-terminal-helper" | ||
- name: /usr/local/bin/qvm-file-manager | ||
- target: /usr/local/bin/qvm-terminal | ||
- user: root | ||
- group: root | ||
- force: True | ||
- makedirs: True | ||
|
||
"{{ slsdotpath }}-copy-to-dom0-helper": | ||
file.managed: | ||
- name: /usr/local/bin/qvm-copy-to-dom0 | ||
- source: salt://{{ slsdotpath }}/files/bin/qvm-copy-to-dom0 | ||
- mode: "0755" | ||
- user: root | ||
- group: root | ||
- makedirs: True | ||
|
||
{% endif -%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{# | ||
SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. <[email protected]> | ||
|
||
SPDX-License-Identifier: AGPL-3.0-or-later | ||
#} | ||
|
||
base: | ||
'dom0': | ||
- match: nodegroup | ||
- dom0.helpers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{# | ||
SPDX-FileCopyrightText: 2023 - 2024 Benjamin Grande M. S. <[email protected]> | ||
|
||
SPDX-License-Identifier: AGPL-3.0-or-later | ||
#} | ||
|
||
{% if grains['nodename'] == 'dom0' -%} | ||
|
||
{% load_yaml as defaults -%} | ||
name: {{ slsdotpath }} | ||
force: True | ||
features: | ||
- set: | ||
- qubes-vm-update-if-stale: 4 | ||
- qubes-vm-update-max-concurrency: 4 | ||
- qubes-vm-update-restart-system: 1 | ||
- qubes-vm-update-restart-other: 0 | ||
{%- endload %} | ||
{{ load(defaults) }} | ||
|
||
{% endif -%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{# | ||
SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. <[email protected]> | ||
|
||
SPDX-License-Identifier: AGPL-3.0-or-later | ||
#} | ||
|
||
base: | ||
'dom0': | ||
- match: nodegroup | ||
- dom0.update-settings |