0

Simple question. Under custom keyboard shortcuts I have tried xterm ~/Desktop/folder/subfolber/textfile but that does not work.

It's my understanding that keyboard shortcuts are terminal commands. When I enter the above in terminal nothing happens, so I probably have the wrong directory. But if I type sh ~/Desktop/folder/subfolber/textfile in terminal I can run the text file, but then this shortcut does not work if I try and add it via keyboard options.

Any clarification is appreciated.

Sam C
  • 23

1 Answers1

0

Keyboard shortcuts are commands but they belong to daemons, such as gnome-settings-daemon or unity-settings-daemon. In case of X-server in general, regardless of which GUI you use, shortcuts may be altered with xbindkeys app.

However, in your specific case, what you really need to make xterm open and run a script is the following:

  1. Go to Settings -> Keyboard -> Shortcuts -> Custom;
  2. Add a new shorcut; tell it to run xterm with full path to the script , e.g., xterm -hold -e /home/user/bin/myScript.sh
  3. Assign keypress to it.

Note: script must be made executable with chmod 755 /path/to/script.sh

Here's my example:

Script in /home/serg/testScript.sh

#!/bin/bash
printf "This was a triumph\nI'm making a note here, huge success"
df
date

Shortcut setup

enter image description here

Output

enter image description here

Check out my other answers that assign scripts to shortcuts: