I'm trying to set a keyboard shortcut for notify-send $(fortune) but when I activate it, it just sends a notification that says $(fortune) instead of actually giving a fortune. Note that if I run it in the terminal, it works as intended (i.e. sends a notification with the result of fortune). This seems to imply that when the keyboard shortcut is activated, it isn't interpreting it as a bash command, but rather as simply running the program notify-send with argument $(fortune).

How do I get it to interpret it correctly?

Note that I've tried putting it in a shell script and doing sh ~/tell-fortune.sh, but that doesn't work either.


$(...) is a shell feature, and the keyboard shortcut command is not run in a shell.

Try this instead:

sh -c 'notify-send $(fortune)'

As for sh tell-fortune.sh, without giving the full path to tell-fortune.sh, where would sh look for it?

As for sh ~/tell-fortune.sh, ~ is also a shell feature, without a shell, it will look for a file at the relative path ~/tell-fortune.sh, where ~ is taken as-is.

  • So just use the absolute path? – PyRulez Mar 6 '18 at 22:14

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.