Qvm-Run Not Working As Expected

I had to reinstall Qubes recently and I figured while I was at it, I might as well throw a script together that I could run from Dom0 that would set everything up for me. Maybe this is a bad idea and you can tell me why.

Anyway, the primary objective of the script is to clone two copies of the default debian and whonix templates, one for disposables and the other for everything else, give all clones a default dark theme per the instructions here, upgrade each clone to the testing branch, install whatever software I deem necessary for each, and finally create the AppVMs and configure their application menus. Dom0 is also set to dark theme and the keyboard/mouse should be given default access to Dom0 (because I’m not paranoid enough to deal with that frustration) via the same script.

But passing commands to the cloned TemplateVMs from Dom0 is not having the same effect as initiating those commands from within the TemplateVM. Specifically, it seems that special characters are ignored such as newlines as well as escaped characters like quotations. Here’s me install script:


#sudo qubesctl state.sls qvm.usb-keyboard

# Sets up dark mode on Dom0
echo "Reminder: Don't forget to change the Xfce theme in Appearances to 'adwaita-dark'"
sudo qubes-dom0-update qt5-qtstyleplugins
echo "QT_QPA_PLATFORMTHEME=gtk2" >> /etc/environment

# Clone a working and dvm copy of the default Debian VM
qvm-clone debian-XX debian-XX-WORKING
qvm-clone debian-XX debian-11-DVM
# Create the Debian disposable template
qvm-create --template=debian-11-DVM --label=RED debian-11-dvm
qvm-prefs debian-11-dvm template_for_dispvms TRUE 
# Clone a working and dvm copy of the default Whonix-Workstation VM
qvm-clone whonix-ws-YY whonix-ws-YY-WORKING
qvm-clone whonix-ws-YY whonix-ws-YY-DVM

# Upgrade the Debian and Whonix-Workstation VMs to the testing repositories
qvm-run 

# Sets up dark mode on the working/dvm VMs
## Debian-11-WORK
qvm-run debian-XX-WORKING "sudo bash -c 'echo Xft.dpi: 96 >> /etc/X11/Xresources/x11-common'" --pass-io --nogui
### settings.ini file
qvm-run debian-XX-WORKING "sudo mkdir -p /etc/skel/.config/gtk-3.0" --pass-io --nogui
qvm-run debian-XX-WORKING "sudo bash -c 'echo -e [Settings] > /etc/skel/.config/gtk-3.0/settings.ini'" --pass-io --nogui
qvm-run debian-XX-WORKING "sudo bash -c 'echo -e gtk-application-prefer-dark-theme=1 >> /etc/skel/.config/gtk-3.0/settings.ini'" --pass-io --nogui
qvm-run debian-XX-WORKING "sudo bash -c 'echo -e gtk-font-name=DejaVu Sans Book 12 >> /etc/skel/.config/gtk-3.0/settings.ini'" --pass-io --nogui
qvm-run debian-XX-WORKING "sudo bash -c 'echo -e gtk-theme-name=Adwaita-dark >> /etc/skel/.config/gtk-3.0/settings.ini'" --pass-io --nogui
qvm-run debian-XX-WORKING "sudo bash -c 'echo -e gtk-icon-theme-name=gnome >> /etc/skel/.config/gtk-3.0/settings.ini'" --pass-io --nogui
### .gtkrc-2.0 file
qvm-run debian-XX-WORKING "sudo bash -c 'echo -e include "/usr/share/themes/Adwaita-dark/gtk-2.0/gtkrc'" > /etc/skel/.gtkrc-2.0" --pass-io --nogui
qvm-run debian-XX-WORKING "sudo bash -c 'echo -e include "/usr/share/themes/Adwaita-dark/gtk-2.0/gtkrc"\nstyle "user-font"\n{\n		font_name="DejaVu Sans Book"\n}\nwidget_class "*" style "user-font"\ngtk-font-name="DejaVu Sans Book 12"\ngtk-theme-name="Adwaita-dark"\ngtk-icon-theme-name="gnome'" > /etc/skel/.gtkrc-2.0" --pass-io --nogui
### RUN THIS COMMAND FROM DOM0
qvm-run debian-XX-WORKING "echo -e ""include \"/usr/share/themes/Adwaita-dark/gtk-2.0/gtkrc\""\n"style \"user-font\""\n{\n"           font_name=\"DejaVu Sans Book\""\n}\n"widget_class \"*\" style \"user-font\""\n"gtk-font-name=\"DejaVu Sans Book 12\""\n"gtk-theme-name=\"Adwaita-dark\""\n"gtk-icon-theme-name=\"gnome\""" > ~/.gtkrc-2.0 && sudo cp ~/.gtkrc-2.0 /etc/skel/.gtkrc-2.0" --pass-io --nogui



### copy both files to TemplateVM's home directory so the dark theme applies to it as well
qvm-run debian-XX-WORKING "cp /etc/skel/.gtkrc-2.0 ~/.gtkrc-2.0 && cp /etc/skel/.config ~/.config"

The bit under ###RUN THIS COMMAND FROM DOM0 bit is giving me grieft. The one-line is supposed to create the .gtkrc-2.0 file in the template VM’s home directory and then copy it to /etc/skel. Launching the command as is from Dom0 produces a single line with missing quotations, but everything from echo.../etc/skel/gtkrc-2.0 works if done from the template VM.

1 Like

Probably won’t help, but I always use --pass-io right after qvm-run, then I tend to use cat with a single quote, but I really couldn’t offer exact command

1 Like

The simple solution is to write the files to Dom0 and qvm-copy-to-vm them.