Different qvm-open-in-dvm for different filetypes

Basically, for my case it is as follows.

Files

  1. I have set different dvm-templates for different file types (filetype-based-dvm-template)
  2. In a desired qube (desired-qube), via context menu I have set default app for each file type as

qvm-open-in-vm @dispvm:filetype-based-dvm-template

  1. For the desired qube, in dom0 I had to set policy for each file type for the desired qube

qubes.OpenInVM * desired-qube @dispvm:filetype-based-dvm-template allow

because the last policy line is, and I don’t want to be asked for certain filetypes

qubes.OpenInVM * @anyvm @anyvm ask

Links

I) If default dispvm is browser-based-dvm-template (that has browser installed in it), it should be enough to set

xdg-mime default qvm-open-in-dvm.desktop x-scheme-handler/http
xdg-mime default qvm-open-in-dvm.desktop x-scheme-handler/https

II) If default dispvm is not browser-based-dvm-template, then:

  1. I created qvm-open-http(s)-in-dvm.desktop file with the content as follows and placed it into /usr/share/applications directory.

[Desktop Entry]
Version=1.0
Name=Open Links In DisposableVM
Exec=/usr/bin/qvm-open-in-vm – @dispvm:browser-based-dvm-template %u
Terminal=false
Type=Application
Categories=Network;WebBrowser;
MimeType=application/octet-stream;application/pdf;application/qubes-untrusted-file;application/rdf+xml;application/rss+xml;application/vnd.mozilla.xul+xml;application/x-wwf;application/x-zerosize;application/xhtml+xml;application/xml;image/gif;image/jpeg;image/png;image/svg+xml;text/html;text/plain;text/xml;x-scheme-handler/about;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/unknown;
NoDisplay=true

Please note that instead browser-based-dvm-template, the one has to set their template.

  1. Checked /.local/share/applications folder, and if found there any instance of qvm-open-http(s)-in-dvm.desktop files (multiple can have additional random characters!), plus the original one with the given name - deleted them all (!) and it started to work!

This to work for links in terminal, I enabled hyperlinks in it’s Settings as well as what I used was an option to middle click links in order to open them, so I could avoid accidental openings by left/right clicks.

Side note for the future users they should not forget: after each policy change, qubesd has to be restarted id dom0, in order the change to become effective:

$ systemctl restart qubesd

1 Like