summaryrefslogtreecommitdiffstats
path: root/audio/sndio/rc.sndiod
diff options
context:
space:
mode:
Diffstat (limited to 'audio/sndio/rc.sndiod')
-rw-r--r--audio/sndio/rc.sndiod57
1 files changed, 57 insertions, 0 deletions
diff --git a/audio/sndio/rc.sndiod b/audio/sndio/rc.sndiod
new file mode 100644
index 0000000000..25cd33b30c
--- /dev/null
+++ b/audio/sndio/rc.sndiod
@@ -0,0 +1,57 @@
+#!/bin/sh
+# Start/stop/restart sndiod(8).
+
+_prefix='/usr'
+_sndiod="$_prefix/bin/sndiod"
+_pkill="$_prefix/bin/pkill"
+_ps="$_prefix/bin/ps"
+_grep="/bin/grep"
+
+# Start sndiod:
+sndiod_start() {
+ if $_ps aux | $_grep -v grep | $_grep $_sndiod > /dev/null
+ then
+ echo 'sndiod is already running.'
+ else
+ $_sndiod
+ fi
+}
+
+# Stop sndiod:
+sndiod_stop() {
+ $_pkill -f $_sndiod
+}
+
+# Restart sndiod:
+sndiod_restart() {
+ sndiod_stop
+ sleep 1
+ sndiod_start
+}
+
+# Check if sndiod is running
+sndiod_status() {
+ if $_ps aux | $_grep -v grep | $_grep $_sndiod > /dev/null
+ then
+ echo 'sndiod is running.'
+ else
+ echo 'sndiod is not running.'
+ fi
+}
+
+case "$1" in
+'start')
+ sndiod_start
+ ;;
+'stop')
+ sndiod_stop
+ ;;
+'restart')
+ sndiod_restart
+ ;;
+'status')
+ sndiod_status
+ ;;
+*)
+ echo "usage $0 start|stop|restart|status"
+esac