Ubuntu – Keyboard shortcut for Thunar custom actions

shortcut-keysthunar

Is it possible to add keyboard shortcuts to thunars custom actions?
I tried setting the key with mouse-over (the needed option is set in xfce settings) but that do not work for me.

Best Answer

Yes this is possible.

This is an example for the standard custom action "Open Terminal Here":

Open the file /home/username/.config/Thunar/accels.scm

than you have to search for:

;  (gtk_accel_path "<Actions>/ThunarActions/uca-action-1398672656481710-1" "")

uca stands for an custom action and the 1 at the end stands for the first action.

Change this line as follows ( Alt+t is only an example you can chose what you want ):

  (gtk_accel_path "<Actions>/ThunarActions/uca-action-1398672656481710-1" "<Alt>t")

enter image description here

be sure you have removed the ";" at the beginning, to uncomment the line!

To activate the shortcut logout:

xfce4-session-logout --logout

and log in again.

Open Thunar, press Alt+t this should be open the "Open Terminal Here" action.

Edit 1: The pagination of the custom action are not always in a logical order. To find the right ID (unique-id) you can look into the /home/username/.config/Thunar/uca.xml file:

enter image description here

Edit 2: Sometimes the shortcuts stops working for me, for example if an confirmation box from Thunar pops up. The consequence is that the focus from the Thunar window are lost. In order to get it back to work you have to make a right click in the Thunar window.

Edit 3: (This is a hint from a anonymous user, not tested)

To avoid the problems explained under Edit 2, you have to modify the /home/username/.config/Thunar/uca.xml file. First you have to change the Line: sh -c "cd %f; x-terminal-emulator" making the lowercase f to an uppercase F.

Second you have to add following lines:

    <audio-files/>
    <image-files/>
    <other-files/>
    <text-files/>
    <video-files/>

this is what the code lookes like after the change:

<action>
    <icon>utilities-terminal</icon>
    <name>Open terminal here</name>
    <unique-id>1557579822897820-1</unique-id>
    <command>sh -c &quot;cd %F; x-terminal-emulator&quot;</command>
    <description></description>
    <patterns>*</patterns>
    <directories/>
    <audio-files/>
    <image-files/>
    <other-files/>
    <text-files/>
    <video-files/>
</action>

Restart Thunar and you're done.