Feeds:
Posts
Comments

Archive for the ‘Keyboard Shortcuts’ Category

One option that most Linux users find invaluable is being able to open a terminal pointing to the current folder, and while file-managers like Nautilus, Nemo and Caja don’t ship with that by default, it’s easily installed with a plugin or extension: nautilus-open-terminal, nemo-terminal and, in the case of Caja, caja-open-terminal (which also gets installed with the caja-extensions package).

While in Nautilus the only way to access that is via a right-click, in Nemo you can actually add a button for it to the toolbar. I couldn’t find a way to add an Open in Terminal button to Caja’s toolbar, likely because it is provided by an extension, not built into Caja, so I wanted to see if I could create a keyboard shortcut for it. But it seems there is a general issue with Caja extensions being that they cannot set keyboard shortcuts for their menu items, because libcaja-extension doesn’t provide this ability.

But you can get around this with a script, and you don’t even need to have caja-open-terminal installed, as long as caja-actions is installed (run sudo apt-get install caja-actions if it isn’t). And the best part is you can even assign an accelerator (keyboard shortcut or hotkey) to it. For me, hitting the F4 key is quicker and easier than clicking a toolbar button, so I’ll show you how to create the script and assign a hotkey to it. Note that you can use another function key, or assign a key-combo, as long as it isn’t already being used for another task, but the F4 is a great choice, as it isn’t already used by Caja or the system.

Creating the “Open Terminal Here” Script

When it comes to creating scripts, most guides out there err on the side of caution and instruct you to create file-names all in lower-case, and with dashes replacing spaces, like open-terminal-here, but there is absolutely no reason for this – your scripts will work just fine with names like Open Terminal Here, and will look nicer in the Scripts sub-menu:

Create a text file called Open Terminal Here for the script in ~/.config/caja/scripts/ with:

pluma ~/.config/caja/"Open Terminal Here"

Paste the following code into it:

#!/bin/sh
#
# This script opens a mate-terminal window in the current directory.
#
# Note that you need to have caja-actions installed to use scripts.

cd $CAJA_SCRIPT_CURRENT_URI
exec mate-terminal

If you want to use another terminal, then replace mate-terminal with gnome-terminal (which is my personal preference), xfce-terminal, konsole, or other terminal of your choice. Save the file, then make it executable with:

chmod +x ~/.config/caja/scripts/"Open Terminal Here"

Before continuing, you need to totally quit Caja, as it will keep overwriting the next file you’ll be adding the shortcut key to; and because Caja is always running in the background in MATE, instead of the usual caja -q, you need to run:

pkill -KILL caja

Assigning the Hotkey for the Script

Then to edit Caja’s “accelerators” file, run:

pluma ~/.config/caja/accels

Your new script should have been automatically added to the accels file, so look for the following line (USER will actually be your username in lower-case):

; (gtk_accel_path "<Actions>/ScriptsGroup/script_file:\\s\\s\\shome\\sUSER\\s.config\\scaja\\sscripts\\sOpen%20Terminal%20Here" "")

First, delete the semi-colon and space at the beginning of the line, then add the shortcut key in between the quotes at the end, so it looks like:

(gtk_accel_path "<Actions>/ScriptsGroup/script_file:\\s\\s\\shome\\sUSER\\s.config\\scaja\\sscripts\\sOpen%20Terminal%20Here" "F4")

Save the file and close it, open Caja, and now the F4 key will open a terminal with its path being the current folder.

The Keyboard Shortcut Not Working?

If you found it almost impossible to edit the accels file (like what happened to me) because something keeps trying to write to it, and Pluma keeps wanting to reload the file, it’s because Caja is being obstinate, and is still running in the background. While killing Caja before editing accels works fine for most people, with the hotkey immediately working, you might need to get more aggressive with Caja, so check out the Successfully Editing ACCELS tutorial to see how I got around this annoyance.

☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻

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!

Buy Ubuntu Genius a Beer to say Thanks!

Read Full Post »

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!

Buy Ubuntu Genius a Beer to say Thanks!

Read Full Post »