CAJA KEYBINDINGS: Applying Keyboard Shortcuts to Scripts via ACCELS Takes FOREVER!

I've been trying to figure out what's making it so hard for me to get keybindings to stick for Caja scripts I've created. After adding the key-combo to a script's entry in the ~/.config/caja/accels file the effect should be immediate - but this is far from the case. While they will eventually stick - the keyboard shortcuts keep getting removed as accels refreshes itself, and I have to keep adding them back – it can be many hours. It took 2 days of this for the last shortcut to finally get registered, and logging out – even rebooting – had no effect. The time between defining the shortcut and it being available is totally random (from a few minutes to 2 days), and I simply can't make sense of it, since it's not like I am doing anything wrong like trying to define a shortcut with a keybinding that is already used elsewhere. So it's not that I can't get them to work, but that I can't get the effect to be immediate, which logic says it should be, and the delay is driving me nuts.

And, before you ask, I always remove the semi-colon and space at the beginning of the line when adding the key-combo, as apparently that's needed, and sometimes I've done that repeatedly for the same entry. As well as replace the keybinding which keeps getting removed.

I've seen in the forums mention of a can-change-accels option in Dconf at /org/mate/desktop/interface/ but it no longer exists (I guess this was retired?). I'd ask for a command that can add that back, but I suspect its exclusion is by design, probably because that's enabled by default. So does anyone know what is going on here, and how I can fix this? Or does this sound like a bug I should be reporting? Many thanks in advance for your help!

A page over at the Linux Mint forums implies that you need to quit Caja right before you edit the accels file, then you have to quit it again after you've made the edits:

https://forums.linuxmint.com/viewtopic.php?p=1817169&sid=6ba64af2b69c03c6475d1b3e2f6e3d5e#p1817169

If that somehow doesn't work, I'd hate to suggest this willy-nilly, but you can edit the accels file, save it, and then immediately kill Caja so that it doesn't have a chance to overwrite your accels file, if you find that the above doesn't work:

pkill -KILL caja

However, I've never found that I've needed to kill Caja like this after editing accelerators.

Gordon, I have actually tried quitting Caja before editing, as it was one of the first things I thought of, but no go. BUT I actually did caja -q so I'll definitely try totally killing next time! I'm embarrassed I haven't actually tried that already.

And try quitting Caja right after you finish editing, too. That's probably more important!

OK, seems I have success! Now quitting Caja before editing accels - and even running caja -q during - has never worked, but using pkill did the trick, so thanks to Gordon for that tip! HOWEVER I have to point out that even with Caja killed, something is still trying to write to accels, as evidenced by:

Caja-Accels-Reload

... coming up while defining the key-combo. So even with reloading and saving, or choosing not to reload then saving, it wasn't happening. SO I decided to try killing Caja before, during multiple times, then after saving accels, and then finally the keyboard shortcuts worked immediately.

So if anyone else is having the difficulties getting custom keyboard shortcuts to work immediately, then the plan of attack is to:

  1. pkill -KILL caja to totally kill Caja
  2. Open the accels file with: gedit ~/.config/caja/accels (you can use pluma instead of gedit)
  3. pkill -KILL caja to totally kill Caja (AGAIN)
  4. Remove the semi-colon and space from the beginning of the line you're going to edit, then Save
  5. pkill -KILL caja to totally kill Caja (AGAIN)
  6. Add your accelerator to the end of the entry, then Save
  7. pkill -KILL caja to totally kill Caja (AGAIN)
  8. If your text editor says the file has changed, click the Reload button, check your edits are still there, and edit them again if not
  9. pkill -KILL caja to totally kill Caja (AGAIN)
  10. Now Save the file, exit, and finally:
  11. pkill -KILL caja to totally kill Caja (a final time)

All that killing Caja might seem excessive, and like I am being cheeky, but seriously it was quicker and easier to just have another terminal open, hit the up arrow, and repeating that than going through the alternative. And, as you could see, Caja was killed BUT something was still trying to write to the accels file (maybe Caja itself, somehow?).

So while I am still curious as to what is writing to accels after Caja has been killed, or how Caja is doing the writing to the file even after being killed - and if you know the answer to either, please feel free to enlighten me - I count this (flawed but workable) success enough to mark this as SOLVED.

PS: Gordon, how do I mark this as SOLVED? I can't see anything in the edit menu or anything - so do I just edit the title with [SOLVED] at the beginning? I'd prefer to do this the correct way, but can't find an option for that, like the Ubuntu Forums has.

And I actually marked your comment with the pkill as the Solution, then marked mine the same, since it has the full sequence of things to do, and seems you can only mark one as the Solution, so thanks again for suggesting that!

FYI, you CAN'T "quit" caja. Ever. It's what runs the desktop too, so just closing any visible file windows still leaves that base copy running. That's why you need to kill it.

Yeah, I got that. But I wasn't expecting I'd need to kill it constantly while editing accels. As described above, even running pkill -KILL caja still had Caja trying to write to accels. At least I assume it was Caja, as pkill doesn't seem to let you know if there wasn't a process to kill, like killall does.

I expect you're right that it was caja. (Though that does rather beg the question as to WHY it's constantly spamming the accels to disk, rather than not being insane and only updating them when they're actually changed).
Since it's considered a critical piece of the desktop, chances are it's either forked from a process that restarts it immediately when it ends (kitchensinkd doubtless has support for this by now), or a watchdog that restarts it within a few seconds - hence the need to keep re-killing it.

1 Like

Caja is respawned by the MATE Session Manager. To prevent it from getting respawned, you can use:

gsettings set org.mate.session.required-components filemanager ''

...but it looks like you'll have to log out and log back in before the change takes effect.

Gordon, I just posted in the other thread how I changed that value back to caja because of that endless loop of Caja opening the 3 folders in my daily_folders script every time I did pkill -KILL caja, haha. Not going there again, buddy! At least I can kill Caja now - having to pkill its background process constantly while editing accels is a small price to pay, and at least it works. I must say MATE is very... entertaining.