When adding (or editing) accelerators (keyboard shortcuts) for tasks in Caja by editing its accels file, you need to first
quit Caja, otherwise you’ll likely find it keeps trying to write to the file. And running caja -q is probably not enough, but using pkill -KILL caja should do the trick. And for most people defining new hotkeys for tasks in Caja, that’s all it takes.
HOWEVER, I had an absolute nightmare with this, because even with Caja killed, something (ie: Caja) was still trying to write to accels, as evidenced by:
… coming up while defining the accelerator. So even with reloading and saving, or choosing not to reload then saving, it wasn’t happening. I’d find the semi-colon and space I had deleted from the beginning of the line back again, and even when that stopped happening, the key I had assigned as the accelerator had been deleted. So, I was in this constant loop of editing the file and saving it, and instead of the shortcut working immediately, I was lucky if I got it recognised after a few minutes of this, and the worst was one that still didn’t stick after 2 days!
And I did try killing Caja more than once, but the results were random. So I decided to try killing Caja before editing accels, 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 open accels in one terminal, and have another terminal open to kill Caja, which you can then easily repeat by hitting the up-arrow and Enter:
First totally kill Caja:
pkill -KILL caja
Then open the accels file in another terminal window with:
pluma ~/.config/caja/accels
Totally kill Caja (AGAIN) – just hit the up-arrow to bring back the last command:
pkill -KILL caja
Remove the semi-colon and space from the beginning of the line you’re going to edit, then Save.
Totally kill Caja (AGAIN):
pkill -KILL caja
Add your accelerator to the end of the entry, then Save.
Totally kill Caja (AGAIN):
pkill -KILL caja
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.
Totally kill Caja (AGAIN):
pkill -KILL caja
Now Save the file, exit, and finally:
Totally kill Caja (AGAIN):
pkill -KILL caja
All that killing Caja might seem excessive, and like I am being cheeky, but seriously it is quicker and easier to just have another terminal open, hit the up arrow, and repeat the kill command than go through the hellish alternative. Now you should find your new hotkey works immediately after starting Caja again.
☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻
The tutorial above is TOTALLY FREE, and I hope you found it useful! But if this information really made your day, because it rescued you from hours of headache, or allowed you to accomplish something you thought was impossible, then please consider making a donation via PayPal, to buy me a donut, beer, or pizza for my time and effort! Many thanks in advance!