diff --git a/bin/play_button b/bin/play_button index 4941336..1e465ff 100755 --- a/bin/play_button +++ b/bin/play_button @@ -40,7 +40,12 @@ toggle_play_songs() { fi if command_exists mpc; then - mpc toggle + if mpc status | grep playing >/dev/nul + then + mpc stop + else + mpc play + fi fi } diff --git a/packages/satellite/config/launcher b/packages/satellite/config/launcher new file mode 100755 index 0000000..8063134 --- /dev/null +++ b/packages/satellite/config/launcher @@ -0,0 +1,16 @@ +#!/bin/sh + +echo 'START' > /tmp/satellite.log + +amixer sset 'pdm dclk' 'pdm dclk 3.072m, support 8k/16k/32k/48k' & amixer sset 'HCIC shift gain from coeff' 'shift with -0x4' >> /tmp/satellite.log +amixer set notifyvol 60% >> /tmp/satellite.log +python3 -m venv .venv >> /tmp/satellite.log + +script/run --name $HOSTNAME --uri 'tcp://0.0.0.0:10700' --no-zeroconf \ +--mic-command '/data/satellite/recorder' \ +--snd-command 'aplay -D notify -r 22050 -c 1 -f S16_LE -t raw' \ +--awake-wav sounds/sound1.wav --done-wav sounds/sound7.wav \ +--startup-command '/bin/show_led 10' --detect-command '/bin/show_led 0' \ +--detection-command '/bin/show_led 1' --stt-stop-command '/bin/show_led 2' --transcript-command '/bin/show_led 0' \ +--error-command '/bin/show_led 7; sleep 1; /bin/show_led 0' \ +--debug >> /tmp/satellite.log 2>&1 diff --git a/packages/satellite/config/satellite.init b/packages/satellite/config/satellite.init new file mode 100755 index 0000000..e81e63b --- /dev/null +++ b/packages/satellite/config/satellite.init @@ -0,0 +1,62 @@ +#!/bin/sh /etc/rc.common + +START=98 +USE_PROCD=1 + +EXTRA_COMMANDS="status toggle" +PIDFILE=/var/run/satellite.pid + +start_service() { + /bin/shut_led 7 & + + procd_open_instance + procd_set_param command /data/satellite/launcher + procd_set_param respawn 3600 5 0 + procd_set_param pidfile ${PIDFILE} + procd_close_instance +} + +stop_service() { + /bin/show_led 7 & + + kill_child_processes 1 `cat ${PIDFILE}` +} + +reload_service() { + stop + sleep 1 + start +} + +toggle() { + if [ -f "${PIDFILE}" ] && [ -e /proc/`cat ${PIDFILE}`/status ]; then + stop + else + start + fi +} + +status() { + if [ -f "${PIDFILE}" ] && [ -e /proc/`cat ${PIDFILE}`/status ]; then + echo "satellite is running." + return 0 + else + echo "satellite is stopped." + return 1 + fi +} + +kill_child_processes() { + isTopmost=$1 + curPid=$2 + childPids=`pgrep -P ${curPid}` + + for childPid in $childPids + do + kill_child_processes 0 $childPid + done + + if [ $isTopmost -eq 0 ]; then + kill -9 $curPid 2> /dev/null + fi +} diff --git a/packages/satellite/config/triggerhappy.conf b/packages/satellite/config/triggerhappy.conf new file mode 100644 index 0000000..f25ac9d --- /dev/null +++ b/packages/satellite/config/triggerhappy.conf @@ -0,0 +1 @@ +KEY_HOME 1 /etc/init.d/listener toggle diff --git a/packages/satellite/package.mk b/packages/satellite/package.mk new file mode 100644 index 0000000..90af31e --- /dev/null +++ b/packages/satellite/package.mk @@ -0,0 +1,19 @@ +PACKAGE_NAME="satellite" +PACKAGE_VERSION="1.1.0" +PACKAGE_SRC="https://github.com/rhasspy/wyoming-satellite/archive/v${PACKAGE_VERSION}.tar.gz" +PACAKGE_DEPENDS="python3 aec-cmdline" + +make_package() { + # TODO +} + +install_package() { + + cp -v ${PACKAGE_DIR}/config/satellite.init ${STAGING_DIR}/etc/init.d/listener + ln -sf ../init.d/listener ${STAGING_DIR}/etc/rc.d/S98listener + + TRIGGERHAPPY_FOLDER="${STAGING_DIR}/etc/triggerhappy/triggers.d" + mkdir -p ${TRIGGERHAPPY_FOLDER} + + cp -v ${PACKAGE_DIR}/config/triggerhappy.conf ${TRIGGERHAPPY_FOLDER}/listener.conf +}