2022-11-14 08:07:30 -05:00
|
|
|
#!/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
|
2022-12-08 00:47:02 -05:00
|
|
|
sleep 0.05
|
|
|
|
if [[ -f ~/.agmsilent ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
2022-11-14 08:07:30 -05:00
|
|
|
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
|
2023-03-06 21:00:46 -05:00
|
|
|
spd-say -w -- "$cliptext"
|
2022-11-14 08:07:30 -05:00
|
|
|
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
|
2023-03-06 21:00:46 -05:00
|
|
|
spd-say -- "$cliptext"
|
2022-11-14 08:07:30 -05:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
exit 0
|