Friday, November 25, 2011

Keyboard shortcut for open terminal here in thunar

Thunar has a right-click custom action, where one open a terminal in the same directory in which one is working. However, I personally miss the option of assigning a keyboard shortcut for the above job (as in pressing ``F4" in konqueror). Work regarding this has already started as said here.
However, until this is implemented directly within thunar, I have written a shell script to do the above job. In other words, keyboard shortcut for opening a terminal in the working directory of thunar is possible now.

Requirements

The following are the requirements which the script depends upon. Install them in ubuntu via apt-get or synaptic.
sudo apt-get install xdotool xclip thunar xfce4-terminal

Installation of script

Download the script from here and rename it ``thunar-terminal.sh". Installation of script is as in installation of most shell script. Make the script executable and move it to your $PATH.
chmod +x thunar-terminal.sh
mkdir -p ~/bin/
mv thunar-terminal.sh ~/bin/

Window manager configuration

This configuration sets ``F4" as the global shortcut. However, the shortcut works only if Thunar window is active. Otherwise, nothing happens.
I work in Openbox window manager with Thunar as file-manager. So I can only talk about keyboard configuration of openbox. However, any window/desktop manager worth it's salt usually allows its users to configure global keyboard shortcuts.
The keyboard configuration for openbox is as follows. Open the file ~/.config/openbox/rc.xml and copy these lines under
<!-- Keybindings for running applications -->
<keybind key="F4">
      <action name="execute">
        <execute>thunar-terminal.sh</execute>
      </action>
    </keybind>
Now logout and login.

Thunar configuration

Thunar also requires a bit of configuration. I have noticed that the script works best if ``Location Selector" of thunar is in ``Toolbar Style". To select the ``Toolbar Style" of Thunar $ >$ View $ >$ Location Selector $ >$ Toolbar Style.
Now press ``F4" and watch as the xfce4-terminal opens in the working directory of Thunar.