I am using this module gtts-cli for text to speech conversion.

more info here-> https://gtts.readthedocs.io/en/latest/cli.html

Basic syntax is

$ gtts-cli 'hello' --output /tmp/hello.mp3 && vlc --play-and-exit /tmp/hello.mp3 && rm /tmp/hello.mp3

I want to write a bash script where the highlighted text (from firefox for example) is sent as a variable to the text portion (in quotes) in the above syntax. I'm on Wayland so I can't use xsel. Then, after VLC finishes playing the mp3 file, I would like vlc to autoclose itself and finally delete the generated mp3 file. Ultimately, I would like to bind the script to a keyboard shortcut. Highlight some text on the screen, then run the script using the shortcut.

Is there an easier way to achieve this? gtts-cli 'hello' outputs a bunch of random characters. Is it possible to pipe the stdoutof gtts-cli 'hello' as stdin to VLC?

1 Answer 1


in wayland you can use wl-clipboard as a clipboard, then you can use an input event like sxhkd in X , for wayland Hawck, evscript and evdevremapkeys...

  • can you help me with the basic syntax of assigning a variable to the clipboard content on wl-clipboard? wl-copy > $x && gtts-cli '$x' something like that? I have no idea where to start.
    – an0nhi11
    Commented Oct 8, 2021 at 18:57
  • use double quotes: gtts-cli "$(wl-paste)" --output /tmp/hello.mp3 && vlc --play-and-exit /tmp/hello.mp3 && rm /tmp/hello.mp3
    – nextloop
    Commented Oct 8, 2021 at 19:09
  • The above command would require me to copy the text first(using ctrl+c) then run the script. Is there a way to run the wl-copy command on the selected text first then chain it with && the above command?I tried to assign wl-copy to a shortcut, then highlight a text, then pressed the shortcut. I was not able to copy the selected text onto the clipboard.
    – an0nhi11
    Commented Oct 8, 2021 at 19:21
  • 1
    <ctrll+c> ==> en terminal echo "text" | wl-copy or wl-copy "Hello world!" or wl-copy < ~/Pictures/photo.png
    – nextloop
    Commented Oct 9, 2021 at 5:25
  • 2
    so it's easy with piple like ./app.sh | wl-copy
    – nextloop
    Commented Oct 9, 2021 at 5:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .