1

I created a custom keyboard shortcut, <ctrl> + <alt> + <shift> + T that would call the command xdotool key --clearmodifiers ctrl+F10 e; however, it does not work. I know that the shortcut is being recognized properly because if I change the command to just gnome-terminal, a terminal window will open as expected. So for some reason xdotool is just not running as a command. I know that the command works on its own because if I run the command in the terminal myself, it works just fine.

The purpose for this is that I want to open a terminal in the current nautilus working directory which you can do by pressing ctrl_F10 and then e, but I wanted to use another keyboard shortcut for that with the gnome keyboard shortcuts.

Kalcifer
  • 233
  • consider making a script for it and calling it with, for example, bash <scriptpathandname.sh' ... also consider an alias and call that with bash -i -c "aliasname" ... maybe a delay after --clearmodifiers ---delay 100 – pierrely Apr 21 '21 at 05:43
  • By "command works on its own", do you mean the gnome-terminal or the xdotool key --clearmodifiers ctrl+F10 e? If you mean the latter my answer makes no sense and I'll remove it. – cprn Jul 30 '21 at 12:45

2 Answers2

1

• First note that, for the Ctrl+F10 to work, the file pane must be active. For me, for example, the shortcut does not work when starting up Files, because the keyboard focus is in the left bar. So when testing, ensure that the file pane is in focus.

• For me, what works more reliably than -clearmodifiers is to explicitly clear the shortcut you assign to the command. Instead, I would rather insert a keyup command, as in:

xdotool keyup ctrl+alt+shift+t key ctrl+F10 e

With these two precautions, I believe it should work, although it is sometimes needed to insert a small delay:

xdotool keyup ctrl+alt+shift+t sleep 0.2 key ctrl+F10 e

Experiment with the value of the sleep command: perhaps it must be longer than 0.2 s.

Some related remarks

You are asking what could be considered an XY question here. Your real problem, X, is how to assign a custom shortcut to "Open terminal here" in Nautilus. You however ask about problem Y, which is about what you think is the best solution to solve problem X.

Unfortunately, methods to do so have systematically been broken. Up to Files in Ubuntu 20.04, you still could conveniently work around with the ~/.config/nautilus/scripts-accels file, where you could define a shortcut to a nautilus script. That approach also does not anymore work in Ubuntu 20.10. So I encourage you to continue exploring this option. However, you would better work with a script that first checks whether the current window is nautilus before activating the xdotool command. Gnome shortcut definitions are global, and are triggered also when you are in a different application.

vanadium
  • 88,010
1

Check whether your Ubuntu session is Xorg or Wayland. Tools like xdotool aren't compatible with Wayland and Wayland became default in newer Ubuntu versions so it switches on upgrade.

$ echo $XDG_SESSION_TYPE 
wayland

You can switch back to Xorg by editing config file:

$ sudo gedit /etc/gdm3/custom.conf

Uncomment (i.e. remove # from the beginning of) the following line:

#WaylandEnable=false

Save the file, reboot and try something like xdotool mousemove 50 20 in terminal, it should teleport your mouse pointer near the upper left corner of the screen.

cprn
  • 1,169
  • 2
  • 12
  • 22
  • 1
    Thank you so much! Fixed issue on Ubuntu 21.04 with KeePass2 global hotkeys. – Alexander Shagin Oct 14 '21 at 18:03
  • Glad to hear. There was some talk about Wayland getting its own wdotool but there's no due date for this. If it happens, all software depending on xdotool (including KeePass2) should switch to support both. Until then this seems to be the best solution. – cprn Oct 15 '21 at 02:14