How do I launch a bash script using a keyboard shortcut?

6,548

I have a keyboard shortcut to launch a script to start conky for me.

Now it sounds like you have tried to 'all the right things'. In the command section of keyboard shortcuts I have: /home/karl/bin/start-conky.sh

If you have cd ~/Downloads && ./bash-script.sh in that field have you tried changing it to: /home/username/Downloads/bash-script.sh?

Share:
6,548

Related videos on Youtube

Alucai Vivorvel
Author by

Alucai Vivorvel

Longtime Linux fan, especially of Ubuntu, which I have used to bring life back to a few of my machines. (They both run Windows 7 albeit slowly.) I enjoy tinkering with things and customizing, but sometimes I run into trouble while doing so, which is why I joined here! I am a hardcore Xbox 360, PC, and Nintendo (wait what) gamer. Also a furry and brony.

Updated on September 18, 2022

Comments

  • Alucai Vivorvel
    Alucai Vivorvel over 1 year

    Just like the title says, how do I launch a bash script in my ~/Downloads folder using a keyboard shortcut? I've tried binding cd ~/Downloads && ./bash-script.sh to different accelerators (ex. the "Tools" button or music player button on my keyboard, and F4) but no luck, yes the script is marked executable, I am trying to do this under "Custom Shortcuts" in System Settings -> Keyboard, and the command works in Terminal.

    • Matt Barnes
      Matt Barnes almost 12 years
      have you tried binding '/home/Downloads/bash-script.sh' ? I'm assuming you have your #!/bin/bash as the first line?
  • Alucai Vivorvel
    Alucai Vivorvel almost 12 years
    Thanks, that did it. I'm a little new to making my own scripts. @Matt No, my script starts with "cd ~/Downloads". Should it start with #!/bin/bash? It works regardless.
  • Manuel J. Diaz
    Manuel J. Diaz over 7 years
    @AgentK, your absolute path tip was the key. ~/Downloads/file.sh did not work while /home/usrname/Downloads/file.sh did. Looks like Ubuntu doesn't like ~ for keyboard shortcuts
  • AgentK
    AgentK over 7 years
    Wow. It's good to know this is still an issue.