jpenguin icon

speak selection Linux

jpenguin | PRO | 08/30/25 12:12:32 AM UTC (Edited) | 0 ⭐ | 400 👁️ | Never ⏰ | []
text |

500 B

|

None

|

0 👍

/

0 👎

#!/bin/sh
 # Determine the clipboard command based on the session type
if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
  clip_cmd="wl-paste --primary --no-newline"
else
  clip_cmd="xclip -rmlastnl -o"
fi
 # Retrieve clipboard content and replace newlines with ,,,
clipboard_content=$($clip_cmd | sed -z 's/\n/,,,/g')
 # Escape special characters and pass to SpeechNote
echo "$clipboard_content" | sed 's/[^a-zA-Z0-9]/\\&/g' | xargs flatpak run net.mkiol.SpeechNote --action start-reading-text --text
  

Comments