I use Debian and the gnome desktop environment.
You can set custom keyboard shortcuts.

For example I did [crtl+alt+t] for opening a terminal.
(the command for this is called "gnome-terminal")
And that works.

But when I try to bind the key [F11] to "python3 /somefolder/myscript.py" and I press F11 nothing happens. (when I type the command in a terminal it works but not with this keyboard shortcut)

  • What are you expecting to happen? What does /somefolder/myscript.py do? Are you sure it isn't actually being executed?
    – terdon
    Jun 25 at 12:40
  • @terdon It is a command line script that I wrote for myself and it should ask me for some inputs and then create a folder and some files. Jun 25 at 12:44
  • Then it can't be run as a shortcut, how would it ask for input? You need to run it in a terminal.
    – terdon
    Jun 25 at 12:46
  • @terdon Ok, thanks. Jun 25 at 12:48

If your script requires input, that means it needs to be run in a terminal so you can't just run it as a shortcut. However, what you could do is to use a terminal emulator that offers an option to pass it commands and run that with your shortcut. For example, using gnome-terminal, you could assign a shortcut to this command:

gnome-terminal -- python3 /somefolder/myscript.py

That will open a terminal, run your script in it allowing you to enter input, and then exit. The terminal will stay open though.

Another approach is to use a shell alias instead. Add this line to your shell's initialization file (e.g. ~/.bashrc):

alias foo="python3 /somefolder/myscript.py"

Then open a new terminal and you can now run foo which will execute your script.


You could do something like gnome-terminal -- "python3 /somefolder/myscript.py" to execute it in terminal and see the output.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.