aboutsummaryrefslogtreecommitdiff
path: root/audio/sndio/rc.sndiod
blob: 25cd33b30c94a58f8df59cd7be61a3340509f9f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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