0

I want ubuntu to read aloud something I put on clipboard. I found a solution for that, which is this:

xsel --clipboard | festival --tts

When I try it on terminal, this code works. But when I try to put this command to a shortcut instead, it doesn't work. Nevertheles, if I change the command in shortcuts with 'gedit' for example, it opens gedit. So, the shortcut is also working. What can be the problem over here?

1 Answers1

3

Keyboard shortcut commands do not get interpreted by a shell, so you can't normally use shell features like pipes in them directly.

Change your shortcut command to explicitly run in a Bash shell:

bash -c 'xsel --clipboard | festival --tts'
Byte Commander
  • 107,489
  • It worked. Now I highlight a text, copy it with Ctrl + C, then apply my key stroke. Is it possible to copy the text and apply this command with only one key stroke? – Tugberk Ayar Aug 31 '18 at 21:03
  • Sure, have a look at my other answer over here for monitoring the clipboard for changes and printing them to the terminal continuously: https://askubuntu.com/a/942280/367990 @TugberkAyar – Byte Commander Aug 31 '18 at 21:31
  • Also if this answer solved your question, please consider accepting it by clicking the grey check button on its left. Thanks. – Byte Commander Aug 31 '18 at 21:32