Default applications by file type/cant get rid of ImageMagick

A pair of closely related gripes:

Debian 11.

I created a template (deb11a-internet-dvm) and a DVM template (internet-disposable), and colored the latter orange. (The default DVM template is green, a color I’m not using anywhere else yet [it’s set aside for Windoze], so it will stick out like a sore thumb if it gets used by mistake.)

OK, ImageMagick is basically one of my least favorite pieces of software because you cannot zoom in it by simply grabbing the window border and stretching. If you do that, the damn thing will change the aspect ratio to match your new window size, distorting the image. That’s IF it doesn’t hang or crash as it resizes.

So I installed ristretto on the template mentioned above. Of course, if you “open in dvm” it goes to the preferred software, which is ImageMagick. Opening the “Default Applications” application, it shows ImageMagick the preferred software for dozens [edit: actually about 18, I had it confused with something else] of file types, and changing them all to Ristretto is tedious to say the least. (The best way to find them all is to sort by application, but then when you change one from ImageMagick to Ristretto, the window jump-scrolls to the Ristretto part of the list and you have to scroll back up. And then this process must be repeated every time I regenerate the template. Furthermore, it doesn’t stick when I create internet-disposable from deb11a-internet-dvm, and it must be done again there.)

So I decided to try uninstalling ImageMagick. I did so both on internet-disposable AND deb11a-internet-dvm. (sudo apt remove imagemagick.)

Images sent to the disposable machine STILL open in ImageMagick even though it’s not on that VM or it’s template or the template’s template by any test I can devise.

One thing more annoying than a crappy piece of software is a crappy piece of software that won’t go away. (Yes, I’m thinking of RealPlayer from 20 years ago.)

So one of a multitude of things–1) how is that even happening? 2) How can I stop it from happening so the system will presumably then fall back on Ristretto? 3) Failing that, is there a command line way to list all the mime preferences then alter them? [all of my searches point me to the generic stuff, which is apparently a different animal; if they mention file type tweaking at all, they invariably say to open the GUI based app.]

1 Like

Pointless, changes don’t persist. You just need to remove in the template.

Try this:

  1. Determine the name of the vm that contains the images (from which you’re clicking on “open in dvm”). We’ll call it VM, make sure to change it below.
  2. In dom0:
qvm-prefs $(qvm-prefs VM default_dispvm) template

This will output the template of the default dvm-template used by your VM (which is not necessarily the same dvm-template used to create the VM). If you haven’t changed anything, this should be the same as qubes-prefs default_dispvm.
3. Uninstall imagemagick from the template found with the command in point 2 (note that you might have to also uninstall imagemagick-6-common and imagemagick-6.q16).
4. Shutdown the template (and the dvm-template, if running).

All new dispvms used to open images should no longer have imagemagick installed.

update-alternatives --get-selections
update-alternatives --config <pref>

Dont do this.
imagemagick is a dependency of qubes-core-agent - until that dependency
is removed you are stuck with it.

What you want to do is change the default mime-types currently used by
Many problems that people have in Qubes are actually not Qubes specific.
This is one of those.

You can find many guides online to changing the default application in
Debian, and those should help you. The only Qubes specific part is that
you have to do this in the template: for disposables you could make this
change in the disposable template.

A simple (and quick) way of doing it could be to create a file at
~/.local/share/applications/mimeapps.list (defaults.list also still works)

mkdir -p ~/.local/share/applications/
cp /usr/share/applications/mimeinfo.cache ~/.local/share/applications/defaults.list
sed -i s/display-im6.q16.desktop/ristretto.desktop/ ~/.local/share/applications/defaults.list

(I’ve assumed that the right file is ristretto.desktop)

I never presume to speak for the Qubes team.
When I comment in the Forum or in the mailing lists I speak for myself.

Thanks to the both of you for quick replies.

I was aware of update-alternatives…however, it seems to only function if there is an alternative defined for images…and I couldn’t find such when I listed all known alternatives. Which is why I was trying to look at the individual file extensions through mime.

I did indeed make sure my template was the template used by the DVM template; I created it from that template on the command line with the --template option and it had the correct thing listed in the Qube Manager. Of course, I’m getting the message that that might still be misleading, so I’ll run the check suggested by BEBF738VD to double check.

I will try unman’s solution when I get home to the qube box (which is itself almost a cube in shape), which of course I refer to as qubeville. (That will work for a name until I convert my laptop to qubes; then it will become ambiguous.)

Fortunately I generate all this stuff with scripts (I read a lot of Sven in the first few days) so it’s relatively quick to redo things if I bork the DVM template or something like that. (Which is why, the other day, I had no hesitation in firing up Firefox in that machine just to test something out.) (And that is also why, even though as a user I prefer gui methods, I wanted a command line solution to mass changing of file types.)

Again thanks to the both of you for your answers. I am pretty confident this will get me to the ultimate solution (and of course it will help with other “I hate the default” issues I will have in the future).

File /etc/xdg/mimeapps.list in the base template or file ~/.config/mimeapps.list in the disposable template can list your own default applications, like this:

[Default Applications]

Change the foo.desktop to your favourite viewer’s desktop file. Also see the wonderful Arch Linux wiki for more info: XDG MIME Applications - ArchWiki

1 Like