diff --git a/audiogame-manager.sh b/audiogame-manager.sh index da13b7b..0a7ad82 100755 --- a/audiogame-manager.sh +++ b/audiogame-manager.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash license() { cat << EOF @@ -93,15 +93,16 @@ write_sequence_storm_reader() { # Here-document start cat << "EOF" > ~/.SequenceStormReader #!/usr/bin/env bash - + # Wait for the game to be launched -while ! pgrep -u $USER ^SequenceStorm &> /dev/null ; do +while ! pgrep -u "$USER" ^SequenceStorm &> /dev/null ; do sleep 0.05 done - + export DISPLAY=:0 unset cliptext -while pgrep -u $USER ^SequenceStorm &> /dev/null ; do +socketFile="$(find /tmp -maxdepth 1 -name "orca-*.sock")" +while pgrep -u "$USER" ^SequenceStorm &> /dev/null ; do if [[ "$(uname)" == "Darwin" ]]; then tmp="$(pbpaste 2> /dev/null)" else @@ -114,19 +115,27 @@ while pgrep -u $USER ^SequenceStorm &> /dev/null ; do if [[ "$(uname)" == "Darwin" ]]; then say -v alex -r 300 "$cliptext" else - spd-say -w -r 50 -- "$cliptext" + 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 - spd-say -r 50 -- "$cliptext" + 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 EOF # Here-document end