aboutsummaryrefslogtreecommitdiff
path: root/audio/pulseaudio/rc.pulseaudio
blob: 81c9361d5002b1f826afefc4a465410c3e2fce5a (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
#!/bin/sh

start()
{
  if /usr/bin/sudo -u pulse /usr/bin/pulseaudio --check; then
    echo "pulseaudio is running."
  else
    echo "Starting pulseaudio..."
    /usr/bin/sudo -u pulse /usr/bin/pulseaudio --start --use-pid-file=yes
  fi
}

stop()
{
  if /usr/bin/sudo -u pulse /usr/bin/pulseaudio --check; then
    printf "Stopping pulseaudio..."
    /usr/bin/sudo -u pulse /usr/bin/pulseaudio --kill
    while /usr/bin/sudo -u pulse /usr/bin/pulseaudio --check; do
      printf "."
      sleep 1
    done
    echo "Done"
  else
    echo "pulseaudio is not running."
  fi
}

status()
{
  if /usr/bin/sudo -u pulse /usr/bin/pulseaudio --check; then
    echo "pulseaudio is running."
  else
    echo "pulseaudio is not running."
  fi
}

case "$1" in
'start')start;;
'stop')stop;;
'restart')stop;start;;
'status')status;;
*)echo "$0 start|stop|restart|status"
esac