Trying to add left-click context menu to mate-desktop

how to add left-click context menu to mate-desktop

I am using the Redmond theme on Ubuntu mate-desktop running as a Windows 10 guest on VMWare. I would like to add my own left-click and middle-click actions to the desktop. I've seen suggestions related to caja, gnome, etc., and am just wondering which layer to leverage. Ideally, mate-desktop will have a gui-based way to create custom actions. I do not think this is the case given what I see in mate-tweak and preferences->menu. Other suggestions were to do it at the caja/nautilis or gnome level. I could probably also do it with a mouse app like FastKeys or InputRemapper, but prefer something more "natural" if that makes sense.Does anyone have any suggestions as to the most Mate-like way to do this? (By Mate-like, I mean directly in Mate or in one of the frameworks from which it forked.)

My current research is on caja, which, so far, seems analogous to explorer in Windows 10. For example, I recently ran into an issue in VMWare where the desktop background was not resizing when I resized the VMWare guest window for the vm. (The panels would resize, but I could not right-click (for example) and pull up the context menu on the area of added size. Also, the background image tiled over the new area) Interestingly, if I resized even a very small amount SMALLER, it would refresh and fix it. Also, if I logged out and back in, it would fix it. Eventually, I determined that:

killall caja

Would also refresh the resolution of the display. As such, I theorized that caja was running the desktop as well as the file manager. From there I started also looking into nautilus since caja was forked from nautilus; however, i still have not discovered how to add a left-click menu. Any suggestions on how to go about this would be great. Thanks!

You can try an approach similar to How to change the menu right click on the desktop from Ubuntu Mate 20.04? - #2 by Norbert_X

1 Like

Hi, Norbert_X. That looks very interesting! I will try it late tonight (Austin time) or tomorrow. Thank you so much for sharing.

Hi @Norbert_X ,

I have been trying for a few hours to wrap my head around the extensions. I can successfully mimic what you have done, but pretty much anything I've tried outside of that does not work for me. For example, I tried replacing the screen lock command with "mate-terminal" and did not get a result. To try to debug it, I downloaded the python-caja example, and it also did not work.

I certainly have no idea how I would bind to a left-click on the desktop. Will I need to dig into the Caja source files to understand how to use these extensions?

Update: I tried checking out the options in dconf-editor for marco and caja, and did not see anything particularly relevant. I am thinking of resorting to an overlay like this: , but that somehow feels like cheating. Also, I don't know if it will work well. Again any suggestions are very much appreciated!


It needs some more investigation. You are free to conduct it by yourself and share results here.

Also we can ping some Caja and MATE developers like @vkareh , @raveit65 or @monsta to get some more info about MATE internals.

From your message, it sounds like you modified @Norbert_X 's code, but it didn't have any effect. If that's the case, you might need to find out what's wrong. I was able to easily do what you described by changing the script like this:

    def restore_missing(self, item):
        """Lock session call"""
-       self._run_cmd(['mate-screensaver-command', '--lock'], background=True)
+       self._run_cmd(['mate-terminal'], background=True)

then run killall caja and right-click on my Desktop.


It did in fact work as you have it. I will determine what I had different later today. I do have the following questions:

  1. How would I create a left-click menu on the desktop?
  2. Would this also work for right-clicking on files?
    If so, how would I pass the file and directory information to the script?

(I also tried the context action scripts under .config/caja/scripts, but I couldn't figure it out there either.) Thank you so much!

OK, I cloned Caja, and found where the Python files are read in caja_module.c. I also found an internals pdf in Caja's doc directory (which appears to be from the root project Nautilus) which I am reading now. Any pointers or suggestions are very much appreciated! Thanks.

Still working on it. I figured I'd compile Caja so I could play around in a debugger. My current issue is that I cannot find a .pc file for libgail-3-0. Please do let me know if there is a quicker way to come up to speed enough to get that left-click menu on the desktop and context actions and menus for my files.

You should enable Source Code repositories in Software & Updates (software-properties-gtk) and then get all the build dependencies for Caja using below commands:

sudo apt-get update
sudo apt-get build-dep caja

I also recommend to hack Caja version which is shipped with your Ubuntu MATE version. So you can run

apt-get source caja

and then play with it or even make a deb-package of it. VM snapshots will allow you to play without problems.

Regarding search of relevant .pc files or any other you can use package contents search on . Exact search results for gail-3.0.pc is here.

That worked. Thank you so much! Please let me know if you have any suggestions on how to best start familiarizing myself with the code.

So far I've read caja_internals.pdf, the style guide, and other docs in the docs directory. I have also been perusing caja-module.c (add_module_objects). Are there any specific files/functions/classes and/or workflows you would suggest to help me get started? When trying to test Caja, I've tried running the executable created in the src directory as well as the one in the .lib directory, but they do not seem to reflect my changes (which are, so far, just changing the help->about as so:

gtk_show_about_dialog (GTK_WINDOW (user_data),
                       "program-name", _("Caja"),
                       "title", _("About Mark's Cool Caja"),
                       "version", VERSION,
                       "comments", _("Mark's Cool Caja (Mcc) lets you organize "
                                     "files and folders, both on "
                                     "your computer and online."),

with no changes visible when I run either of the local the local executables called 'caja'; however, I am sure I will solve this new mystery quickly enough).

Well, it works now after replacing the executable (/usr/bin/caja) with the new one, and then running:

killall caja

Still have a mystery to solve someday as to why I couldn't just run the local copy as:


but I'll take it! Cheers.