Nautilus/Caja Script to "Extract Here" Selected RAR/Archive(s) via Engrampa, File-Roller or Command?
I'm looking to create a file manager script to use in Caja (I used "Nautilus Script" in the title so people would understand what I was trying to accomplish) that will extract the selected archive (or multiple archives) to the current location. Preferably I'd like to specify Engrampa to do the extracting, but File-Roller, or even a command, would be fine (though I'd prefer to have the progress dialog pop up like when I extract them via "Extract Here").
Now, you may be wondering why I want a script for this when Caja has the "Extract Here" option in the context menu, just like Nautilus. The reason is that I've had great success assigning keyboard shortcuts to the scripts I use in Caja, so my objective is to be able to extract the selected archive(s) with a key-combo like Alt+X.
I have very limited expertise in scripts, but have managed to do some basic, but very useful, things like the following, which is open the selected image in Gimp, which I've assigned the combo Alt+I to:
#!/bin/bash
if mimetype -b "$1" | grep image; then
gimp "$1"
fi
I've used that same approach for a couple of other things that work great, like opening a folder with an image viewer, but trying to create a script for extracting the selected archive (specifically RAR, as that is what I most download) with Engrampa (engrampa -h) to the current folder, or even just the Unrar command (unrar e), nothing happens. I think the mimetype is specified correctly, I've tried it with engrampa minus the -h option to see if Engrampa pops up (all my working scripts have no option after the command), yet nothing happens at all. So, obviously I am doing something wrong with the script below:
#!/bin/bash
if mimetype -b "$1" | grep application/x-rar-compressed; then
engrampa -h "$1"
fi
So I am calling on your expertise to solve this. While it's not crucial, as I can do it with a right-click, it would be great to get this happening, so I can assign a key-combo to it. I'd be happy with a script just for use with RAR files, though one that will extract any type of archive would of course be most welcome. And while I'd prefer a GUI app to do this, so I can see the progress, it's not vital. Many thanks in advance, and stay safe everybody!
PS: I am using Ubuntu 20.04, in case that matters. And I switched to Caja a week ago, as the Nautilus devs keep removing functionality.