Moved the sequence storm reader to a more generic clipboard_reader.sh script. There very well could be bugs, so please report if you find them.
This commit is contained in:
44
speech/clipboard_reader.sh
Executable file
44
speech/clipboard_reader.sh
Executable file
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Wait for the game to be launched
|
||||
while ! pgrep -u "$USER" ^$1 &> /dev/null ; do
|
||||
sleep 0.05
|
||||
done
|
||||
|
||||
unset cliptext
|
||||
socketFile="$(find /tmp -maxdepth 1 -name "orca-*.sock")"
|
||||
while pgrep -u "$USER" ^$1 &> /dev/null ; do
|
||||
if [[ "$(uname)" == "Darwin" ]]; then
|
||||
tmp="$(pbpaste 2> /dev/null)"
|
||||
else
|
||||
tmp="$(xclip -d "${DISPLAY:-:0}" -selection clipboard -o 2> /dev/null)"
|
||||
fi
|
||||
tmp="${tmp//%/ percent }"
|
||||
if [ "$tmp" != "$cliptext" ] ; then
|
||||
cliptext="$tmp"
|
||||
if [[ "${cliptext,,}" =~ key|load|private|says|terminal ]]; then
|
||||
if [[ "$(uname)" == "Darwin" ]]; then
|
||||
say -v alex -r 300 "$cliptext"
|
||||
else
|
||||
if [[ -w "${socketFile}" ]]; then
|
||||
echo "<#APPEND#>$cliptext" | socat - UNIX-CLIENT:"${socketFile}"
|
||||
else
|
||||
spd-say -w -r 50 -- "$cliptext"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if [[ "$(uname)" == "Darwin" ]]; then
|
||||
say -v alex -r 300 "$cliptext"
|
||||
else
|
||||
if [[ -w "${socketFile}" ]]; then
|
||||
echo "$cliptext" | socat - UNIX-CLIENT:"${socketFile}"
|
||||
else
|
||||
spd-say -r 50 -- "$cliptext"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
sleep 0.05
|
||||
done
|
||||
|
||||
exit 0
|
Reference in New Issue
Block a user