Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filecopy GUI error message and kdialog progress bar fixes #476

Merged
merged 5 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions qubes-rpc/gui-fatal.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,13 @@ static void produce_message(const char *type, const char *fmt, va_list args)
case 0:
if (geteuid() == 0) {
if (setuid(getuid()) != 0) {
perror("setuid failed, not calling kdialog/zenity");
perror("setuid failed, not calling zenity/kdialog");
exit(1);
}
}
fix_display();
#ifdef USE_KDIALOG
execlp("/usr/bin/kdialog", "kdialog", "--sorry", dialog_msg, NULL);
#else
execlp("/usr/bin/zenity", "zenity", "--error", "--text", dialog_msg, NULL);
#endif
execlp("/usr/bin/kdialog", "kdialog", "--sorry", dialog_msg, NULL);
exit(1);
default:;
}
Expand Down
28 changes: 19 additions & 9 deletions qubes-rpc/qvm-copy-to-vm.gnome
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,19 @@

set -e -o pipefail

set_qdbus() {
for cmd in qdbus qdbus-qt{6,5}; do
type "$cmd" >&2 || continue
qdbus=$cmd
return 0
done

unset qdbus
return 1
}

copy() {
/usr/lib/qubes/qrexec-client-vm @default \
PROGRESS_TYPE=gui /usr/lib/qubes/qrexec-client-vm @default \
qubes.Filecopy /usr/lib/qubes/qfile-agent "$@"
}

Expand All @@ -33,11 +44,10 @@ progress_kdialog() {
if [[ $pos == 0 ]]; then
# shellcheck disable=SC2207
ref=( $(kdialog --progressbar "$DESCRIPTION") )
trap 'qdbus "${ref[@]}" close' EXIT # for this subshell
qdbus "${ref[@]}" Set "" maximum "$SIZE"
trap '"$qdbus" "${ref[@]}" close' EXIT # for this subshell
fi

qdbus "${ref[@]}" Set "" value "$pos"
"$qdbus" "${ref[@]}" value $((100 * pos / SIZE))
done) >/dev/null # hide qdbus's empty output lines
}

Expand Down Expand Up @@ -79,11 +89,11 @@ else
fi

if [[ $SIZE == 0 ]]; then
PROGRESS_TYPE=none copy "$@"
elif [[ $0 == *.kde ]] && type kdialog qdbus >/dev/null; then
PROGRESS_TYPE=gui copy "$@" | progress_kdialog
copy "$@" >/dev/null
elif [[ $0 == *.kde ]] && type kdialog >/dev/null && set_qdbus; then
copy "$@" | progress_kdialog
elif type zenity >/dev/null; then
PROGRESS_TYPE=gui copy "$@" | progress_zenity
copy "$@" | progress_zenity
else
PROGRESS_TYPE=none copy "$@"
copy "$@" >/dev/null
fi